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