about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/main.c1
-rw-r--r--src/pause.c98
2 files changed, 64 insertions, 35 deletions
diff --git a/src/main.c b/src/main.c
index c25de51..f556f98 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,4 @@
 #include "pong.h"
-#include <raylib.h>
 
 int Difficulty = 1;
 SDL_atomic_t Ticks;
diff --git a/src/pause.c b/src/pause.c
index c785c66..11c2e9d 100644
--- a/src/pause.c
+++ b/src/pause.c
@@ -6,32 +6,32 @@ bool pause_screen(Camera2D *MainCamera) {
 	
 	/* Mouse */
 	Rectangle Mouse = {
-        1280.0f/2, 720.0f/2, 10, 10
-    };
-    Vector2 OldPosition = GetMousePosition();
-    Vector2 NewPosition = GetMousePosition();
-    Texture2D MouseCursor = LoadTexture("resources/cursor.png");
-    bool MouseCursorIn = true;
-    DisableCursor();
-
+        	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) {
 		/* 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)) {
 			return false;
@@ -39,28 +39,58 @@ bool pause_screen(Camera2D *MainCamera) {
 			return true;
 		}
         
-        if (IsKeyPressed(KEY_ESCAPE)) {
-            EnableCursor();
-            MouseCursorIn = false;
-        } else if (IsCursorOnScreen() && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
-            DisableCursor();
-            MouseCursorIn = true;
-        }
+		if (IsKeyPressed(KEY_ESCAPE)) {
+            		EnableCursor();
+            		MouseCursorIn = false;
+        	} else if (IsCursorOnScreen() && IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
+            		DisableCursor();
+            		MouseCursorIn = true;
+        	}
+		if (IsKeyPressed(KEY_A)) {
+			Choice--;
+		} else if (IsKeyPressed(KEY_D)) {
+			Choice++;
+		}
+
+		if (Choice >= 2) {
+			Choice = 1;
+		} else if (Choice <= -1) {
+			Choice = 0;
+		}
+
 		BeginDrawing();
-		ClearBackground(BLACK);
+			ClearBackground(BLACK);
 			BeginMode2D(*MainCamera);
-			DrawRectangle(0, 0, 1280, 720, (Color){20,20,20,255});
+				DrawRectangle(0, 0, 1280, 720, (Color){20,20,20,255});
 				if(CheckCollisionRecs(Mouse, (Rectangle){1280/3.0f, (720/3.0f)+50, 100, 50})) {
-					DrawRectangle((1280/3.0f)-5, (720/3.0f)+50, 104, 50, RED);
+					Choice = 0;
 					if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
 						return false;
 					}
 				} else if(CheckCollisionRecs(Mouse, (Rectangle){(1280/3.0f)+150, (720/3.0f)+50, 70, 50})) {
-					DrawRectangle((1280/3.0f)+150,(720/3.0f)+50, 70, 50, RED);
+					Choice = 1;
 					if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
 						return true;
 					}
 				}
+				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 (IsKeyPressed(KEY_SPACE)) {
+					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);