GetKeyState too Sticky

Started by
1 comment, last by Verg 18 years, 8 months ago
I'm using GetKeyState for input in a project I'm working on and I'm having some trouble with it. For example: 1) User presses E to enter Weapon Shop. 2) User now has the option to press E to select a Weapon, but as soon as the user enters the shop a weapon is selected, it would seem that the previous pressing of E has been passed over. I have some sleep() after getting key states, but that doesn't seem to change much. Any ideas? Is there a way to "remove" or release the current key state before proceeding to something else? Changing the user's input option (i.e. pressing X instead of E on the second part) isn't really an option I want to look into.
Advertisement
Just save the state of the key each frame and only execute an action if the state changes from KeyUp to KeyDown, that way you only activate the action once when the key is pushed down.
GetAsyncKeyState
my_life:          nop          jmp my_life
[ Keep track of your TDD cycle using "The Death Star" ] [ Verge Video Editor Support Forums ] [ Principles of Verg-o-nomics ] [ "t00t-orials" ]

This topic is closed to new replies.

Advertisement