[SDL] Event handling questions
serenity at nosubstancesoftware.com
Thu Jul 25 03:04:01 PDT 2002
I'm writing a game in c++ using SDL.
I'm curious as to the best way to handle events from SDL.
I have separate objects for the various players, and each player needs to
detect if the appropriate keys have been pressed or not.
The best way, I assume, is to poll through the events at the point I need
The problem is that if I poll through the events in one player's object,
then the key press may be removed and not detected again when the second
player's controls come around.
The other way, I guess, is to pump_events at the beginning of my loop and
check the status of the various keys at the end.
I've been trying the second way, but sometimes my game goes crazy with
events that seem to hang around in the queue.
When I call pump_events does this clear the current event queue?
I was wondering if other people had any ideas as to how best to manage game
input when requiring input detection in various locations.
More information about the SDL