diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/controls.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/controls.c b/src/controls.c index 544813e..fca64da 100644 --- a/src/controls.c +++ b/src/controls.c @@ -17,3 +17,21 @@ int player_controls() { } return(-1); } + +/* Same as player_controls() but check if the button was pressed, rather than held down. */ +int player_controls_pressed() { + if( IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_SPACE) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN) ) { + return(CONTROLLER_ACTIVATE); + } else if( IsKeyPressed(KEY_ESCAPE) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_MIDDLE_RIGHT) ) { + return(CONTROLLER_PAUSE); + } else if( IsKeyPressed(KEY_A) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_LEFT) ) { + return(CONTROLLER_LEFT); + } else if( IsKeyPressed(KEY_D) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT) ) { + return(CONTROLLER_RIGHT); + } else if( IsKeyPressed(KEY_W) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_UP) ) { + return(CONTROLLER_UP); + } else if( IsKeyPressed(KEY_S) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_DOWN) ) { + return(CONTROLLER_DOWN); + } + return(-1); +} |