[SDL] Problem moving a blitted image,
Torsten Giebl
wizard at syntheticsw.com
Mon Mar 5 17:13:11 PST 2007
Hello !
> Alright I've came to a problem and found out that even time I move my
> image I have to constantly click down on the DOWN arrow key to move it
> and It won't keep moving as I hold the arrow keys. Does anyone know
> how to make my script so when I hold down on the arrow keys that it
> keeps moving until I release up on a arrow key?
SDL uses the OS event system, which most of the time
acts like a state machine. Which means it only send events
when something changes.
bool left = false;
bool right = false;
bool up = false;
bool down = false;
Now if you get an Keydown event set the meaned boolean true
like Keydown Event + Left Key: left = true;
KeyUp Event + Left Key: left=false;
For the rest of the keys do the same or use SDL_GetKeyState.
Then in your loop simply asks if left == true the move left.
The same with the other keys.
CU
More information about the SDL
mailing list