Use of Signals for card game

Started by
1 comment, last by frob 12 years ago
I'm currently working on my own Yu-Gi-Oh! Game (I know, there are a lot of people AND a big company working on it, but it's perfect practice for me) and I think of a "Send Signal"-System everytime a player summons a monster or activates a spell/trap card. Now the problem is how to generate such a signal handler:

  • Shall I use a static class (all variables and methods are static) which tells each card what has been played/activated?
  • Is <csignal> of any use for this?
  • Shall I generate an instance of signal handler and send its reference to each Card (SignalHandler& sig_handler;)?

Would be happy for any advice from you. LG rumpfi88
Advertisement
I'd just recommend a plain old consumer-producer model - but I use that pretty much everywhere c:
Those signals are generally used for interprocess communication. That is, if you want to send a message to another different process.

Many games will implement their own event listeners; this model is supported by most modern languages where you can register event listeners, and easily broadcast to all interested listeners.

A simple search for "games message event bus" gives a bunch of useful descriptions of how to implement them, many including source code.

This topic is closed to new replies.

Advertisement