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.
C++ Key Press?
Moderator: Coders of Rage
Re: C++ Key Press?
Just for future reference, it's usually helpful to list the API/Library you are using.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.
Re: C++ Key Press?
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
if you are using an API such as SDL, there is an event called SDL_KEYDOWN you can check when polling for events