diff options
Diffstat (limited to 'src/pause.c')
-rw-r--r-- | src/pause.c | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/pause.c b/src/pause.c index c3264ec..fa5e97a 100644 --- a/src/pause.c +++ b/src/pause.c @@ -1,51 +1,51 @@ -#include "pong.h" #include <raylib.h> +#include "pong.h" + bool pause_screen(Camera2D *MainCamera) { bool PauseScreenGoing = true; - + /* Mouse */ Rectangle Mouse = { - 1280.0f/2, 720.0f/2, 10, 10 - }; + 1280.0f / 2, 720.0f / 2, 10, 10}; Vector2 OldPosition = GetMousePosition(); Vector2 NewPosition = GetMousePosition(); Texture2D MouseCursor = LoadTexture("resources/cursor.png"); bool MouseCursorIn = false; EnableCursor(); int Choice = 0; - while(PauseScreenGoing == true && GameGoing == true) { + while (PauseScreenGoing == true && GameGoing == true) { /* Update Camera */ - MainCamera->zoom = GetScreenHeight()/720.0f; - MainCamera->offset = (Vector2){GetScreenWidth()/2.0f, GetScreenHeight()/2.0f}; - MainCamera->target = (Vector2){1280/2.0f, 720/2.0f}; + MainCamera->zoom = GetScreenHeight() / 720.0f; + MainCamera->offset = (Vector2){GetScreenWidth() / 2.0f, GetScreenHeight() / 2.0f}; + MainCamera->target = (Vector2){1280 / 2.0f, 720 / 2.0f}; /* Mouse */ - if (MouseCursorIn == true) { - OldPosition = NewPosition; - NewPosition = GetMousePosition(); - Mouse.y -= OldPosition.y-NewPosition.y; - Mouse.x -= OldPosition.x-NewPosition.x; - if (Mouse.y >= 720 || Mouse.y <= 0) { - Mouse.y += OldPosition.y-NewPosition.y; - } - if (Mouse.x >= 1280 || Mouse.x <= 0) { - Mouse.x += OldPosition.x-NewPosition.x; - } - } + if (MouseCursorIn == true) { + OldPosition = NewPosition; + NewPosition = GetMousePosition(); + Mouse.y -= OldPosition.y - NewPosition.y; + Mouse.x -= OldPosition.x - NewPosition.x; + if (Mouse.y >= 720 || Mouse.y <= 0) { + Mouse.y += OldPosition.y - NewPosition.y; + } + if (Mouse.x >= 1280 || Mouse.x <= 0) { + Mouse.x += OldPosition.x - NewPosition.x; + } + } - if(IsKeyPressed(KEY_Y)) { + if (IsKeyPressed(KEY_Y)) { return false; - } else if(IsKeyPressed(KEY_N)) { + } else if (IsKeyPressed(KEY_N)) { return true; } - + if (IsKeyPressed(KEY_ESCAPE)) { EnableCursor(); MouseCursorIn = false; - } else if (IsCursorOnScreen() && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { + } else if (IsCursorOnScreen() && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { DisableCursor(); - MouseCursorIn = true; - } + MouseCursorIn = true; + } if (player_controls() == CONTROLLER_LEFT) { Choice--; } else if (player_controls() == CONTROLLER_RIGHT) { @@ -59,36 +59,36 @@ bool pause_screen(Camera2D *MainCamera) { } BeginDrawing(); - ClearBackground(BLACK); - BeginMode2D(*MainCamera); - DrawRectangle(0, 0, 1280, 720, (Color){20,20,20,255}); - if(CheckCollisionRecs(Mouse, (Rectangle){1280/3.0f, (720/3.0f)+50, 100, 50})) { - Choice = 0; - } else if(CheckCollisionRecs(Mouse, (Rectangle){(1280/3.0f)+150, (720/3.0f)+50, 70, 50})) { - Choice = 1; - } - switch(Choice) { - case 0: - DrawRectangle((1280/3.0f)-5, (720/3.0f)+50, 104, 50, RED); - break; - default: - DrawRectangle((1280/3.0f)+150,(720/3.0f)+50, 70, 50, RED); - break; - } - if ( player_controls() == CONTROLLER_ACTIVATE ) { - switch(Choice) { - case 0: - return false; - break; - default: - return true; - break; - } - } - DrawText("Paused. Exit?", 1280/3, 720/3, 48, WHITE); - DrawText("YES NO", 1280/3, (720/3)+50, 48, WHITE); - DrawTexture(MouseCursor, Mouse.x, Mouse.y, WHITE); - EndMode2D(); + ClearBackground(BLACK); + BeginMode2D(*MainCamera); + DrawRectangle(0, 0, 1280, 720, (Color){20, 20, 20, 255}); + if (CheckCollisionRecs(Mouse, (Rectangle){1280 / 3.0f, (720 / 3.0f) + 50, 100, 50})) { + Choice = 0; + } else if (CheckCollisionRecs(Mouse, (Rectangle){(1280 / 3.0f) + 150, (720 / 3.0f) + 50, 70, 50})) { + Choice = 1; + } + switch (Choice) { + case 0: + DrawRectangle((1280 / 3.0f) - 5, (720 / 3.0f) + 50, 104, 50, RED); + break; + default: + DrawRectangle((1280 / 3.0f) + 150, (720 / 3.0f) + 50, 70, 50, RED); + break; + } + if (player_controls() == CONTROLLER_ACTIVATE) { + switch (Choice) { + case 0: + return false; + break; + default: + return true; + break; + } + } + DrawText("Paused. Exit?", 1280 / 3, 720 / 3, 48, WHITE); + DrawText("YES NO", 1280 / 3, (720 / 3) + 50, 48, WHITE); + DrawTexture(MouseCursor, Mouse.x, Mouse.y, WHITE); + EndMode2D(); EndDrawing(); } return true; |