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?

  • \$\begingroup\$ How can you check if someone made a move if you don't run something continuously to do just that? \$\endgroup\$ – user15805 Jan 29 '13 at 20:24
  • \$\begingroup\$ Using events/messages, as is common in GUI applications. \$\endgroup\$ – drxzcl Jan 29 '13 at 20:36
  • \$\begingroup\$ Doesn't then, an event listener, have to continuously <listen>? \$\endgroup\$ – user15805 Jan 29 '13 at 20:39
  • \$\begingroup\$ Or from another point of view, remain active? \$\endgroup\$ – user15805 Jan 29 '13 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 Jan 29 '13 at 20:54

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.