Jump to content

  • Log In with Google      Sign In   
  • Create Account


Use of Signals for card game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 rumpfi88   Members   -  Reputation: 185

Like
0Likes
Like

Posted 09 April 2012 - 11:24 AM

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

Sponsor:

#2 Neglected   Members   -  Reputation: 111

Like
0Likes
Like

Posted 09 April 2012 - 01:18 PM

I'd just recommend a plain old consumer-producer model - but I use that pretty much everywhere c:

#3 frob   Moderators   -  Reputation: 19633

Like
1Likes
Like

Posted 09 April 2012 - 01:58 PM

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.
Check out my personal indie blog at bryanwagstaff.com.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS