about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c9
-rw-r--r--src/marathon.c12
-rw-r--r--src/pong.h2
-rw-r--r--src/title.c3
-rw-r--r--src/versus.c13
5 files changed, 31 insertions, 8 deletions
diff --git a/src/main.c b/src/main.c
index 5f733f5..a638248 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,13 +1,11 @@
 #include "pong.h"
 #include "sounds.h"
-#include <raylib.h>
-#include <setjmp.h>
-#include <threads.h>
 
 
 int Difficulty = 1;
 atomic_int Ticks = 0;
 bool GameGoing = true;
+char *VersionString;
 
 mtx_t AudioQueueBeingModified;
 
@@ -99,12 +97,15 @@ int main() {
 	//Raylib Init
 	InitWindow(1280, 720, "Pong");
 	SetTargetFPS(60);
-	SetExitKey(KEY_Q);
+	SetExitKey(KEY_NULL);
 	Image Icon = LoadImage("resources/ball.png");
 	SetWindowIcon(Icon);
 	SetWindowState(FLAG_VSYNC_HINT);
 	SetWindowState(FLAG_WINDOW_RESIZABLE);
 	SetWindowMinSize(1280, 720);
+
+	//Init Variables
+	strcpy(VersionString, "Version 0.2 - AEOLUS");
 	
 	//Populate Audio Queue
 	for(unsigned int i = 0; i < 20; i++) {
diff --git a/src/marathon.c b/src/marathon.c
index 0ec4f71..9e05b7a 100644
--- a/src/marathon.c
+++ b/src/marathon.c
@@ -37,8 +37,11 @@ void marathon_main() {
         MainCamera.target = (Vector2){0, 0};
         MainCamera.offset = (Vector2){0, 0};
         MainCamera.rotation = 0;
-
-    while(!WindowShouldClose() && GameGoing == true) {
+    bool MarathonGoing = true;
+    while(MarathonGoing == true && GameGoing == true) {
+        if (WindowShouldClose()) { //Quit Game if the window is closed.
+            GameGoing = false;
+        }
         UpdateMusicStream(Background);
         snprintf(PlayerScore, 50, "Player: %d", Player.Score);
         MainCamera.zoom = GetScreenHeight()/720.0f;
@@ -56,6 +59,11 @@ void marathon_main() {
 			Player.Y = GetMouseY()-PaddleSprite.height/2.0f;
 			DisableCursor();
 		}
+        
+        // Leave game
+        if(IsKeyPressed(KEY_Q)) {
+            return;
+        }
 		
 		if(GetMouseY() < 0) {
 			SetMousePosition(0, 0);
diff --git a/src/pong.h b/src/pong.h
index 8fb51c5..bb6e522 100644
--- a/src/pong.h
+++ b/src/pong.h
@@ -10,6 +10,7 @@
 #include <stdatomic.h>
 #include <threads.h>
 #include <setjmp.h>
+#include <string.h>
 
 #define LEFT 0
 #define RIGHT 1
@@ -34,6 +35,7 @@ struct Balls {
 extern int Difficulty;
 extern bool GameGoing;
 extern atomic_int Ticks;
+extern char *VersionString;
 
 void enemy(struct Players *Enemy, struct Balls ball);
 void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerScore, int *EnemyScore);
diff --git a/src/title.c b/src/title.c
index c73fb10..7617a7c 100644
--- a/src/title.c
+++ b/src/title.c
@@ -33,6 +33,7 @@ int title_screen() {
     };
     Rectangle *Selected;
     Selected = &Versus;
+    EnableCursor();
     while(!WindowShouldClose() && TitleScreenGoing == true) {
         MainCamera.zoom = GetScreenHeight()/720.0f;
         Mouse.x = GetMouseX()/MainCamera.zoom;
@@ -68,8 +69,8 @@ int title_screen() {
                 DrawText("Settings", 20, 250, 48, WHITE);
                 DrawText("Help", 20, 300, 48, WHITE);
                 DrawText("Exit", 20, 350, 48, WHITE);
-                DrawRectangleRec(Mouse, YELLOW);
             EndMode2D();
+            DrawText(VersionString, GetScreenWidth()-200, GetScreenHeight()-32, 32, GREEN);
         EndDrawing();
     }
     return -1;
diff --git a/src/versus.c b/src/versus.c
index 6d964de..cd57d9a 100644
--- a/src/versus.c
+++ b/src/versus.c
@@ -42,7 +42,13 @@ void versus_main() {
         MainCamera.target = (Vector2){0, 0};
         MainCamera.offset = (Vector2){0, 0};
         MainCamera.rotation = 0;
-    while(!WindowShouldClose() && GameGoing == true) {
+	bool VersusGoing = true;
+    while(VersusGoing == true && GameGoing == true) {
+		
+		if (WindowShouldClose()) { //Quit Game if the window is closed.
+            GameGoing = false;
+        }
+
 		UpdateMusicStream(Background);
 		MainCamera.zoom = GetScreenHeight()/720.0f;
 		MainCamera.offset = (Vector2){GetScreenWidth()/2.0f, GetScreenHeight()/2.0f};
@@ -85,6 +91,11 @@ void versus_main() {
 		} else if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT) || IsCursorHidden() == true) {
 			Player.Y = GetMouseY()-PaddleSprite.height/2.0f;
 			DisableCursor();
+		} 
+		
+		// Leave Game
+		if(IsKeyPressed(KEY_Q)) {
+			return;
 		}
 		
 		if(GetMouseY() < 0) {