Sign in to follow this  
gapern

[SDL] Event queue question

Recommended Posts

Hi. I'm just wondering if the event queue ever needs to be cleared and if so how do I do it? I'm seeing the SDL_FlushEvent function and I'm assuming that's how clearing the queue would be done but I'm not sure if I need too or not. Consider this example code.

[code]
while(key.a != pressed)
{
dostuff();
}

while(key.b != pressed)
{
domorestuff();
}
endprogram();

[/code]

The first loop runs until I hit a. While in the first loop I hit the b key. Assume b is not used in the first loop so it's just stored in the event queue. Now I hit a and break out of the first loop. The program immediately finds b and ends the program but I didn't want the program to end yet.

Is the problem I just pointed out valid?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this