Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualGDsnakes

Posted 03 January 2013 - 12:25 PM

I tried that method. It was the first thing I tried

If I hold down the key the payer doesn't move. I have to repeatedly tap the key. 

 

void handleKeys( unsigned char key, int x, int y )
{
   Uint8 *keystates = SDL_GetKeyState(NULL);

   if( keystates[SDLK_w])
   {
       PlayerY  += 10;
   }
   else if( keystates[SDLK_s])
   {
       PlayerY  -= 10;
   }
   else if( keystates[SDLK_d])
   {
       PlayerX  += 10;
   }
   else if( keystates[SDLK_a])
   {
       PlayerX  -= 10;
   }
}


#1GDsnakes

Posted 03 January 2013 - 12:20 PM

The problem is with the key event messages that he's getting from SDL. He doesn't have a 'pressed' function (unless there's one in SDL that he's not using) - he's trying to create one based on key-up/key-down messages.

There is.  He should look at SDL_GetKeyState()

 

 %


PARTNERS