I can currently move my player over by tapping the key. If I press once moves X units. If I hit twice 2X units, etc.
I want to be able to move the player by holding down the key and then when I let the key up the player stops moving.
This is my current code.
void handleKeys( )
{
if (event.type == SDL_KEYDOWN)
{
switch( event.key.keysym.sym )
{
case SDLK_w:
PBbaseoffY = PBbaseoffY + 10;
break;
case SDLK_s:
PBbaseoffY = PBbaseoffY - 10;
break;
case SDLK_a:
PBbaseoffX = PBbaseoffX - 10;
break;
case SDLK_d:
PBbaseoffX = PBbaseoffX + 10;
break;
}
}
}
I works fine but like I said I want to be able to hold it down to move.