Page 1 of 1
C++ Key Press?
Posted: Sat Nov 28, 2009 11:13 am
by Sk8er
I am very confused on this. Been doing searches on google all morning. Anyone got a decent explanation of how to? I would like WASD and The arrow keys to move a sprite. (Currently in my game its completely random on how the character moves.)
EDIT:: NVM, i got the arrows.
Re: C++ Key Press?
Posted: Sat Nov 28, 2009 11:35 pm
by XianForce
Sk8er wrote:I am very confused on this. Been doing searches on google all morning. Anyone got a decent explanation of how to? I would like WASD and The arrow keys to move a sprite. (Currently in my game its completely random on how the character moves.)
EDIT:: NVM, i got the arrows.
Just for future reference, it's usually helpful to list the API/Library you are using.
Re: C++ Key Press?
Posted: Sun Nov 29, 2009 2:25 am
by DaveB
you can use a combination of _kbhit() (to check if a key was hit) and _getch() (to get the value of the key that was hit).
if you are using an API such as SDL, there is an event called SDL_KEYDOWN you can check when polling for events