4
\$\begingroup\$

The only games I've made have been the game loop variety. I'm just starting to think about building an online poker game where people could meet up in a lobby, etc. Cards seem event based... is the game loop strategy viable here? Or is it just a waste of time to keep running while waiting for someone to make a move?

\$\endgroup\$
8
  • \$\begingroup\$ How can you check if someone made a move if you don't run something continuously to do just that? \$\endgroup\$
    – user15805
    Commented Jan 29, 2013 at 20:24
  • \$\begingroup\$ Using events/messages, as is common in GUI applications. \$\endgroup\$
    – drxzcl
    Commented Jan 29, 2013 at 20:36
  • \$\begingroup\$ Doesn't then, an event listener, have to continuously <listen>? \$\endgroup\$
    – user15805
    Commented Jan 29, 2013 at 20:39
  • \$\begingroup\$ Or from another point of view, remain active? \$\endgroup\$
    – user15805
    Commented Jan 29, 2013 at 20:40
  • \$\begingroup\$ You've never heard of event listeners and/or the Observer pattern? Long story short, yes something does have to be continuously listening, but that something could just be one organized hub rather than everything in the entire game looping over and over. \$\endgroup\$
    – jhocking
    Commented Jan 29, 2013 at 20:54

1 Answer 1

3
\$\begingroup\$

Strictly separate your game engine from the rest of the project, such as GUI, net code, etc. The game engine itself should be event-based, let the OS provide the "game loop" in form of its regular event handling. Make all game events that are relevant to the outside accessible through events to which the GUI and all other parts can subscribe. Then you are free to implement your GUI whichever way you want.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .