Hands-on Rust: ability to clear key buffer?

Title: Hands-On Rust: (Chapter 9)

Feel free to ignore as this is more about game play experience.

I noticed, on my first test of acquiring the amulet, that I zipped right through the Victory screen and into a new game. I’m pretty sure this was because I was just holding down the cursor key to get to the amulet. Maybe something brief could be added to clear the key buffer? (If it’s too “in the weeds”, feel free to ignore suggestion)

1 Like

Thanks again! That’s actually a tough one, because the buffering happens at the OS messaging level rather than a level over which we have direct control. I’ll take another look; one option is to add a timer (count elapsed time since the screen appeared, just like you did for Flappy’s timing) and ignore keyboard input until that happens. Another option is to not accept any key, but require a specific key that isn’t generally used (Q or ESCAPE would work) to exit the menu.

I’ll see if I can clean that up. :slight_smile:

2 Likes