[SDL] Problem moving a blitted image,
Ryan C. Gordon
icculus at icculus.org
Mon Mar 5 21:35:02 PST 2007
> meh If you looked at my code it already does everything your talking
> about(bet you aint even look at the source..)
The users of this mailing list aren't required to fix your bugs. Please
treat them graciously even if you feel their answers are not satisfactory.
Torsten gave you good advice, and actually told you exactly what the
problem was. SDL_KEYDOWN does not fire with any frequency. It happens
once when you push down the key, and SDL_KEYUP happens when you let go.
Checking for SDL_KEYDOWN each time through the loop won't help, since it
will only happen once.
If you want to know if a key is (still) pressed down every frame, use
SDL_GetKeyState() or track it yourself. Torsten told you this, too.
Jeff correctly told you that if you want to have SDL_KEYDOWN show up
multiple times when you hold down a key, use SDL_EnableKeyState().
And I, who _did_ read your source code, will tell you: you have a bug
with where you read and write the "up", "down", "left" and "right"
variables...and also, where you don't.
Also, this:
> if(destination.x <= 0)
> destination.x++;
> else
> destination.x--;
...will keep destination.x between 0 and 1, which probably wasn't what
you wanted.
--ryan.
More information about the SDL
mailing list