diff options
author | Charadon <dev@iotib.net> | 2022-10-12 19:33:13 -0400 |
---|---|---|
committer | Charadon <dev@iotib.net> | 2022-10-12 19:33:13 -0400 |
commit | 1e5c179edbae849d185ab9f2be95233ee60cacbf (patch) | |
tree | bc044d8469428e6ac90e9c2aae6c348f6734f3f8 /src/controls.c | |
parent | 67ac76476ccd5c7cfe9e41f023bee96345710a55 (diff) | |
download | Pong-C-1e5c179edbae849d185ab9f2be95233ee60cacbf.tar.gz |
Fixed formatting FINALLY
Diffstat (limited to 'src/controls.c')
-rw-r--r-- | src/controls.c | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/controls.c b/src/controls.c index a3cefa1..de2520d 100644 --- a/src/controls.c +++ b/src/controls.c @@ -1,41 +1,42 @@ -#include "pong.h" #include <raylib.h> +#include "pong.h" + /* Checks what button the player is pressing amongst all control inputs. */ int player_controls() { - if( IsMouseButtonDown(MOUSE_LEFT_BUTTON) || IsKeyDown(KEY_SPACE) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN) ) { - return(CONTROLLER_ACTIVATE); - } else if( IsKeyDown(KEY_ESCAPE) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_MIDDLE_RIGHT) ) { - return(CONTROLLER_PAUSE); - } else if( IsKeyDown(KEY_A) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_LEFT) ) { - return(CONTROLLER_LEFT); - } else if( IsKeyDown(KEY_D) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT) ) { - return(CONTROLLER_RIGHT); - } else if( IsKeyDown(KEY_W) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_UP) ) { - return(CONTROLLER_UP); - } else if( IsKeyDown(KEY_S) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_DOWN) ) { - return(CONTROLLER_DOWN); + if (IsMouseButtonDown(MOUSE_LEFT_BUTTON) || IsKeyDown(KEY_SPACE) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) { + return (CONTROLLER_ACTIVATE); + } else if (IsKeyDown(KEY_ESCAPE) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_MIDDLE_RIGHT)) { + return (CONTROLLER_PAUSE); + } else if (IsKeyDown(KEY_A) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) { + return (CONTROLLER_LEFT); + } else if (IsKeyDown(KEY_D) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) { + return (CONTROLLER_RIGHT); + } else if (IsKeyDown(KEY_W) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_UP)) { + return (CONTROLLER_UP); + } else if (IsKeyDown(KEY_S) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) { + return (CONTROLLER_DOWN); } - return(-1); + return (-1); } /* Same as player_controls() but check if the button was pressed, rather than held down. */ int player_controls_pressed() { int ReturnVal = -1; - if( IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_SPACE) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN) ) { + if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON) || IsKeyPressed(KEY_SPACE) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) { ReturnVal = CONTROLLER_ACTIVATE; - } else if( IsKeyPressed(KEY_ESCAPE) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_MIDDLE_RIGHT) ) { + } else if (IsKeyPressed(KEY_ESCAPE) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_MIDDLE_RIGHT)) { ReturnVal = CONTROLLER_PAUSE; - } else if( IsKeyPressed(KEY_A) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_LEFT) ) { + } else if (IsKeyPressed(KEY_A) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_LEFT)) { ReturnVal = CONTROLLER_LEFT; - } else if( IsKeyPressed(KEY_D) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT) ) { + } else if (IsKeyPressed(KEY_D) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT)) { ReturnVal = CONTROLLER_RIGHT; - } else if( IsKeyPressed(KEY_W) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_UP) ) { + } else if (IsKeyPressed(KEY_W) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_UP)) { ReturnVal = CONTROLLER_UP; - } else if( IsKeyPressed(KEY_S) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_DOWN) ) { + } else if (IsKeyPressed(KEY_S) || IsGamepadButtonPressed(1, GAMEPAD_BUTTON_LEFT_FACE_DOWN)) { ReturnVal = CONTROLLER_DOWN; } - return(ReturnVal); + return (ReturnVal); } /* Calls BeginDrawing() and EndDrawing() to clear input buffer. */ |