[SDL] Keyboard movement: Can't use two keys at once?

DARKGuy . dark.guy.2008 at gmail.com
Thu Sep 14 01:22:00 PDT 2006


Okay :P I know there's a problem since computers were born (or well... I did
xD) that you couldn't press more than three keys at once. That still exists
in these new systems (no matter what OS you use) and we all can (and do)
live with it. However, there's this little thing that's bugging me now...
I'm using this for moving my spaceship -v

        SDL_PollEvent(&event);
        if (event.type == SDL_QUIT){ salir = 1; }
        if (event.type == SDL_KEYDOWN){
            if(event.key.keysym.sym == SDLK_UP){ Player1->py -= 3; }
            if(event.key.keysym.sym == SDLK_DOWN){ Player1->py += 3; }
            if(event.key.keysym.sym == SDLK_LEFT){ Player1->px -= 3; }
            if(event.key.keysym.sym == SDLK_RIGHT){ Player1->px += 3; }
        }


It works, but only if I press the key once, release it and then hold it
pressed, like a tap (which is not the idea) and also, it doesn't let me
press two keys at once. Say, for moving diagonally, I could press both up
and right keys, but the game doesn't get both keys, just one of them, and
that's not good :(

I tried following a tutorial in this site http://gpwiki.org/index.php/SDL ,
both the keyboard basics and the practical movement one, but I don't see how
SDL_KEYUP would help me in this case... maybe with the having-to-tap-the-key
problem, but not with the diagonal movement...

Any suggestions? ^_^

Thanks in advance :)

- DARKGuy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060914/2dfbe258/attachment-0007.htm>


More information about the SDL mailing list