[SDL] Game event loop and input

Stephen Anthony stephena at roadrunner.nf.net
Thu Jan 30 17:02:00 PST 2003

On January 30, 2003 09:12 pm, Joby Bednar wrote:

> I'm starting to map out the various stages of my game, intro, tutorial,
> game play, cut scenes, etc.  and it is getting a little ugly when it
> comes to what I envision as user input and the basic event loop.  I'm
> thinking I need to create a global that stores the current game state
> and use a series of case statements within the PollEvent loop.  This
> seems a bit bulky though and could run pages long.

Yes, I'm very interested in any info in this area as well.  In my program, 
I call a handleEvents every frame.  I'd like to add a menu to the program 
that will take key events as well.

My solution was to use a handleGameEvents normally, but if in menu mode 
(indicated by some global variable), then to do a handleMenuEvents 

Something makes me think there should be a cleaner way though.  What if I 
want to add a different menu?  Create another function to handle *those* 

I guess what I'd like to know is how to simulate a multi-event paradigm in 
SDL, like one does in a GUI toolkit.


More information about the SDL mailing list