I have been working on a game using Allegro 5, and so far I love it. When playing my game, and my character dies and runs out of lives, the game displays a GAME OVER message then goes back to the main title screen which awaits the player to press any key to continue.
The problem is that sometimes it will display the title screen and then quickly skip past it because the player was holding down an arrow key when they died. Even though they let go of the key before a title screen is displayed, it still seems to be buffered, or in the event queue. A similar problem happens once in a blue moon at start up. The character will show up as already moved off their starting spot, I think due to the same problem.
I want to know is there a way I can clear the keyboard event queue? I have inserted code to wait in a loop if while a key is being pressed, but this will cause possible delays and seems like a hack when clearing the queue/buffer would be a more eloquent solution.
This is what I have been inserting so far...
} while(event.type == ALLEGRO_EVENT_KEY_DOWN);
Any ideas? Or am I stuck with the above code?