[SDL] Game event loop and input

Martin wtxnh-sdl at yahoo.com.au
Sun Feb 10 09:01:55 PST 2008


On Sat, Feb 09, 2008 at 08:31:39PM -0200, Gabriel Gambetta wrote:
> >
> > So what I came up with is kind of similar, I guess. ^_^  I'm not sure
> > why or if the layers idea would be better, but either could be easily
> > done in SDL (on-topic!) and work rather nicely, I think.
> >
> 
> Great minds think alike? ;) Our (http://www.mysterystudio.com) framework is
> based on this same concept (we call them GameModes) and has been used in
> quite a few commercially released games. So it the idea works :)
> 
> About input processing and stuff, our GameModes have a few flags :
> GMF_PASS_INPUT, GMF_PASS_DRAW and GMF_PASS_UPDATE. The flags determine
> whether or not input, a chance to draw, or timer ticks can pass to the mode
> below it in the stack, respectively. Most combinations are useful - for
> example, a full-screen mode (main menu, game screen) have none of the flags
> set. Modal dialogs have PASS_DRAW - you see what's below, but it's stopped.
> Non-modal dialogs have PASS_DRAW | PASS_INPUT | PASS_UPDATE - the mode below
> continues to run while showing the dialog. Finally, remember Doom's map,
> where you saw the 2D overhead map but the game continued to run below?
> PASS_INPUT | PASS_UPDATE. Actually, it was with this last example in mind I
> designed the mode stack and the flags :)
> 
> --Gabriel

This is exactly what I am looking for.
One thing that puzzles me is order of drawing. Suppose you have stack
(man menu, game screen, dialog). When dialog has to be drawn it is drawn
and PASS_DRAW to game screen. When game screen is drawn will it not
overdraw (hide) dialog? I thing that game screen should be drawn first,
then dialog while processing input and update should remain as it is.
Am I wrong?

Since I am not experienced programmer I am still looking for some
example code that has similar functionality as Gabriel and Scott
described. Is there any available?

Martin


More information about the SDL mailing list