[SDL] Flushing Queue

Started by
2 comments, last by Puck 15 years, 3 months ago
Is there any way to flush/clear/free the event queue?
Advertisement
Look at SDL_PeepEvents(). Be careful not to drop important events like SDL_QUIT. Can I ask why you want to do this?
There is a moment in my game where when the player character dies, he is respawned in the center of the screen by gradually appearing (through SDL_SetAlpha). During this time, if the player hits the arrow keys, when the loop that makes him appear is over and the new round of the game begins the character moves because the keyboard press events that were in queue become active.

Is there any other way around this?
I don't know how your code is organized, but I would personally check the event queue within the fade in loop and discard input events you don't care about then and there while responding to events that should logically interrupt the process -- like the SDL_QUIT event that rip-off mentioned.

This topic is closed to new replies.

Advertisement