-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello all,
I' coding my first programs with SDL, and I have found a problem.
I’m sure it’s very easy to solve, but I haven’t been able yet.
I have a duck (“pato”, in Spanish) graphic, which is controlled by
keyboard’s input. I use the following code to build each frame of the
game:
void pasar()
{
SDL_Rect rect;
rect.x=x;rect.y=y;rect.w=pato->w;rect.h=pato->h; //pato is the
surface with the duck’s graphic
while(SDL_PollEvent(&event)==1){
if(event.type==SDL_KEYDOWN &&
event.key.keysym.sym==SDLK_ESCAPE){quit=1;}
if(event.type==SDL_KEYDOWN && event.key.keysym.sym==SDLK_UP &&
y>70){y–;}
if(event.type==SDL_KEYDOWN && event.key.keysym.sym==SDLK_DOWN &&
y<410-pato->h){y++;}
if(event.type==SDL_KEYDOWN && event.key.keysym.sym==SDLK_RIGHT &&
x<570-pato->w){x++;}
if(event.type==SDL_KEYDOWN && event.key.keysym.sym==SDLK_LEFT &&
x>70){x–;}
if(event.type==SDL_QUIT){quit=1;}
}
ciclos_realizados++;
}
Of course, after this I run frame(), blitting everithing needed to
screen.
My problem is that my duck only moves in one direction a time. It
moves vertically and horizontally, but never in a 45? degree (I think
it should, if I press two keys a time).
What should I do?
Thank you very much for your time.
Jes?s Carrete Monta?a ----> KUANTIKO___________________________________________
| .~. |
| /V\ jrcarmon(arroba)teleline.es |
| // \ Linux Registered |
| /( )\ User #158442 |
| ^`~’^ |
|___________________________________________|
Clave p?blica PGP disponible por e-mail.
-----BEGIN PGP SIGNATURE-----
Version: PGP 6.5.1i for non-commercial use http://www.pgpi.com/
iQA/AwUBOU0rbVXBzV6UX+HYEQLcBwCg+HP2EvJ6LF2qsnihGhTuzTDaI4YAn3jx
8qGQFqCYOkAPcfH44xMpYeEQ
=7ojH
-----END PGP SIGNATURE-----