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

Rasmus Neckelmann neckelmann at gmail.com
Thu Sep 14 05:34:31 PDT 2006


On 9/14/06, Sahan Chandrasekara <sahanthegamecreator at gmail.com> wrote:
> so how would you do that with switch/case?

For instance:

...

switch(Event.type) {
  case SDL_KEYDOWN:
    if(Event.key.keysym.sym == SDLK_UP)
      moving_up = true;
    break;
  case SDL_KEYUP:
    if(Event.key.keysym.sym == SDLK_UP)
      moving_up = false;
    break;
}

if(moving_up)
  move_up();

...

or something like that.

-- 
Regards,
Rasmus Neckelmann




More information about the SDL mailing list