[SDL] Problem moving a blitted image,

Lamonte(Scheols/Demonic) scheols at gmail.com
Mon Mar 5 17:36:13 PST 2007


Alright ill try it, im going to recode this script using a switch
statement then make the bools go back to false when I release the key
:) ill report with errors that I have and such.

On 3/5/07, Torsten Giebl <wizard at syntheticsw.com> wrote:
> 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
> _______________________________________________
> SDL mailing list
> SDL at lists.libsdl.org
> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org
>


-- 
Join phpdiscovery.com Now!


More information about the SDL mailing list