From 43a23590acdc63709f4e67a1caf39cf41be32dba Mon Sep 17 00:00:00 2001 From: Charadon Date: Tue, 14 Jun 2022 20:32:17 -0400 Subject: #6 Added pause screen --- src/marathon.c | 20 ++++++++++++-------- src/pong.h | 1 + src/versus.c | 15 +++++++++++---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/marathon.c b/src/marathon.c index c2492a6..07a9fe3 100644 --- a/src/marathon.c +++ b/src/marathon.c @@ -133,7 +133,12 @@ void marathon_main() { } else if (IsKeyDown(KEY_DOWN)) { Player.Y += 10; } else if(IsKeyPressed(KEY_ESCAPE)) { - EnableCursor(); + Mix_PauseMusic(); + BeginDrawing(); + EndDrawing(); + MarathonGoing = pause_screen(&MainCamera); + Mix_ResumeMusic(); + Ball.NextTick = SDL_AtomicGet(&Ticks)+1; } else if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT) || IsCursorHidden() == true) { Player.Y = GetMouseY()-PaddleSprite.height/2.0f; DisableCursor(); @@ -152,16 +157,13 @@ void marathon_main() { Player.Y = 480; } - // Collision + // Collision ball(&Player.HitBox, NULL, &Ball, &Player.Score, NULL); - //Updates hitbox with player's position. + //Updates hitbox with player's position. Player.HitBox.y = Player.Y; // End Game - if(Ball.X < 0 || IsKeyPressed(KEY_Q)) { - if (Player.Score > 0) { - leaderboard_record(Player.Score); - } + if(Ball.X < 0) { MarathonGoing = false; } @@ -176,7 +178,9 @@ void marathon_main() { EndDrawing(); } Mix_HaltMusic(); + if (Player.Score > 0) { + leaderboard_record(Player.Score); + } Mix_FreeMusic(Background); - EnableCursor(); return; } diff --git a/src/pong.h b/src/pong.h index 2e2fd44..dd469f5 100644 --- a/src/pong.h +++ b/src/pong.h @@ -62,5 +62,6 @@ int title_screen(); void versus_main(); void marathon_main(); void set_screen_mode(); +bool pause_screen(Camera2D *MainCamera); #endif diff --git a/src/versus.c b/src/versus.c index 34914bc..7b140ae 100644 --- a/src/versus.c +++ b/src/versus.c @@ -38,9 +38,10 @@ void versus_main() { char PlayerScore[50]; // Used later to display score on screen. // Init Camera Camera2D MainCamera; - MainCamera.target = (Vector2){0, 0}; - MainCamera.offset = (Vector2){0, 0}; - MainCamera.rotation = 0; + MainCamera.target = (Vector2){0, 0}; + MainCamera.offset = (Vector2){0, 0}; + MainCamera.rotation = 0; + bool VersusGoing = true; Ball.NextTick = SDL_AtomicGet(&Ticks); Enemy.NextTick = SDL_AtomicGet(&Ticks); @@ -91,7 +92,13 @@ void versus_main() { } else if (IsKeyDown(KEY_DOWN)) { Player.Y += 10; } else if(IsKeyPressed(KEY_ESCAPE)) { - EnableCursor(); + Mix_PauseMusic(); + BeginDrawing(); + EndDrawing(); + VersusGoing = pause_screen(&MainCamera); + Mix_ResumeMusic(); + Ball.NextTick = SDL_AtomicGet(&Ticks)+1; + Enemy.NextTick = SDL_AtomicGet(&Ticks)+1; } else if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT) || IsCursorHidden() == true) { Player.Y = GetMouseY()-PaddleSprite.height/2.0f; DisableCursor(); -- cgit 1.4.1-2-gfad0 for keyapi.Wrapper' href='/akspecs/ranger/commit/test/tc_keyapi.py?h=v1.5.1&id=a666f32b959416d062ac38645dc27f20686d881b'>a666f32b ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24