whatever: Joystick can can no longer be used with arrows to double speed

This commit is contained in:
Logen Kain 2016-11-12 22:28:07 -07:00
parent 565d2890be
commit cbc6417dfd

View File

@ -71,8 +71,6 @@ int main ( int argc, char *argv[] )
int xDir = 0;
int yDir = 0;
SDL_JoyButtonEvent jbutton;
/* message pump */
while (!gameover)
{
@ -140,35 +138,37 @@ int main ( int argc, char *argv[] )
/* move the player with the above input */
gPlayer_dest.x += xDir;
gPlayer_dest.y += yDir;
const Uint8* currentKeyStates = SDL_GetKeyboardState( NULL );
if (currentKeyStates[ SDL_SCANCODE_ESCAPE ] ||
currentKeyStates[ SDL_SCANCODE_Q ] )
if (xDir != 0 || yDir != 0)
{
gameover = 1;
gPlayer_dest.x += (xDir * movement_speed);
gPlayer_dest.y += (yDir * movement_speed);
}
if (currentKeyStates[ SDL_SCANCODE_LEFT ] )
else
{
gPlayer_dest.x -= movement_speed;
}
if (currentKeyStates[ SDL_SCANCODE_RIGHT ] )
{
gPlayer_dest.x += movement_speed;
}
if (currentKeyStates[ SDL_SCANCODE_UP ] )
{
gPlayer_dest.y -= movement_speed;
}
if (currentKeyStates[ SDL_SCANCODE_DOWN ] )
{
gPlayer_dest.y += movement_speed;
}
const Uint8* currentKeyStates = SDL_GetKeyboardState( NULL );
if (currentKeyStates[ SDL_SCANCODE_ESCAPE ] ||
currentKeyStates[ SDL_SCANCODE_Q ] )
{
gameover = 1;
}
if (currentKeyStates[ SDL_SCANCODE_LEFT ] )
{
gPlayer_dest.x -= movement_speed;
}
if (currentKeyStates[ SDL_SCANCODE_RIGHT ] )
{
gPlayer_dest.x += movement_speed;
}
if (currentKeyStates[ SDL_SCANCODE_UP ] )
{
gPlayer_dest.y -= movement_speed;
}
if (currentKeyStates[ SDL_SCANCODE_DOWN ] )
{
gPlayer_dest.y += movement_speed;
}
}
/* render the background */
SDL_RenderCopy(gRenderer, gBackground_texture, NULL, NULL);
@ -179,10 +179,7 @@ int main ( int argc, char *argv[] )
/* Render here */
SDL_RenderPresent(gRenderer);
}
return 0;
}
int init()