Update controls

This commit is contained in:
Miloslav Číž 2019-10-03 20:24:34 +02:00
parent 82ab9bcb01
commit d3c6a246ed
2 changed files with 54 additions and 11 deletions

7
main.c
View File

@ -521,7 +521,12 @@ void SFG_gameStep()
SFG_player.verticalSpeed = 0; SFG_player.verticalSpeed = 0;
#else #else
RCL_Unit verticalOffset = RCL_Unit verticalOffset =
(SFG_keyPressed(SFG_KEY_JUMP) && (SFG_player.verticalSpeed == 0) && (
(
SFG_keyPressed(SFG_KEY_JUMP) ||
(SFG_keyPressed(SFG_KEY_UP) && SFG_keyPressed(SFG_KEY_C))
) &&
(SFG_player.verticalSpeed == 0) &&
(SFG_player.previousVerticalSpeed == 0)) ? (SFG_player.previousVerticalSpeed == 0)) ?
SFG_PLAYER_JUMP_SPEED : SFG_PLAYER_JUMP_SPEED :
(SFG_player.verticalSpeed - SFG_GRAVITY_SPEED_INCREASE_PER_FRAME); (SFG_player.verticalSpeed - SFG_GRAVITY_SPEED_INCREASE_PER_FRAME);

View File

@ -36,17 +36,55 @@ int8_t SFG_keyPressed(uint8_t key)
{ {
switch (key) switch (key)
{ {
case SFG_KEY_UP: return sdlKeyboardState[SDL_SCANCODE_UP]; break; case SFG_KEY_UP:
case SFG_KEY_RIGHT: return sdlKeyboardState[SDL_SCANCODE_RIGHT]; break; return sdlKeyboardState[SDL_SCANCODE_UP] ||
case SFG_KEY_DOWN: return sdlKeyboardState[SDL_SCANCODE_DOWN]; break; sdlKeyboardState[SDL_SCANCODE_W] ||
case SFG_KEY_LEFT: return sdlKeyboardState[SDL_SCANCODE_LEFT]; break; sdlKeyboardState[SDL_SCANCODE_KP_8];
case SFG_KEY_A: return sdlKeyboardState[SDL_SCANCODE_A]; break; break;
case SFG_KEY_B: return sdlKeyboardState[SDL_SCANCODE_S]; break;
case SFG_KEY_C: return sdlKeyboardState[SDL_SCANCODE_D]; break;
case SFG_KEY_JUMP: return sdlKeyboardState[SDL_SCANCODE_SPACE]; break; case SFG_KEY_RIGHT:
case SFG_KEY_STRAFE_LEFT: return sdlKeyboardState[SDL_SCANCODE_Q]; break; return sdlKeyboardState[SDL_SCANCODE_RIGHT] ||
case SFG_KEY_STRAFE_RIGHT: return sdlKeyboardState[SDL_SCANCODE_E]; break; sdlKeyboardState[SDL_SCANCODE_E] ||
sdlKeyboardState[SDL_SCANCODE_KP_6];
break;
case SFG_KEY_DOWN:
return sdlKeyboardState[SDL_SCANCODE_DOWN] ||
sdlKeyboardState[SDL_SCANCODE_S] ||
sdlKeyboardState[SDL_SCANCODE_KP_5];
break;
case SFG_KEY_LEFT:
return sdlKeyboardState[SDL_SCANCODE_LEFT] ||
sdlKeyboardState[SDL_SCANCODE_Q] ||
sdlKeyboardState[SDL_SCANCODE_KP_4];
break;
case SFG_KEY_A:
return sdlKeyboardState[SDL_SCANCODE_G];
break;
case SFG_KEY_B:
return sdlKeyboardState[SDL_SCANCODE_H];
break;
case SFG_KEY_C:
return sdlKeyboardState[SDL_SCANCODE_J];
break;
case SFG_KEY_JUMP:
return sdlKeyboardState[SDL_SCANCODE_SPACE];
break;
case SFG_KEY_STRAFE_LEFT:
return sdlKeyboardState[SDL_SCANCODE_A] ||
sdlKeyboardState[SDL_SCANCODE_KP_7];
break;
case SFG_KEY_STRAFE_RIGHT:
return sdlKeyboardState[SDL_SCANCODE_D] ||
sdlKeyboardState[SDL_SCANCODE_KP_9];
break;
default: return 0; break; default: return 0; break;
} }