[SDL] Game event loop and input

wtxnh-sdl at yahoo.com.au wtxnh-sdl at yahoo.com.au
Sat Feb 9 05:59:49 PST 2008


I found this post in archive and wanetd to and wanted to examine
the source of Game Framework. But the site is defunc now.

Does anybody know where from can I download the source?

Original mail:
> 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.
>
> Has anyone had experience in developing a custom class that you can use
> to wrap around the event to simplify the event structure with respect
> to your game states?  Or perhaps other ways that you have found
> especially effective in keeping code clean and simple?

The first or second article in `Game Programming Gems 3' is about a
similar topic to this.  He talks about a thing which he calls a Game
Framework.  It has a website - www.gameframework.com - which is updated
reasonably regularly.

The basic concept is that you have `layers' which can each have control.
The layers are, well, `layered' on top of one another.  The top one gets
the first shot at the input, and if it doesn't handle it, the next one
gets a go, and so on.  (There can be exclusive layers which don't give
anyone else a go at the input.)  So the input cascades down the chain of
layers.  A menu can be an exclusive layer which tacks onto the front of
the stack.  You can have different layers for different parts of the
interface.  It's quite flexible, and works pretty well with SDL.

Hope that helps,

Dave.
--
  David Slutzkin, BCS (Hons)
  Melbourne, Australia


More information about the SDL mailing list