summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-06-02 18:39:29 -0400
committerCharadon <dev@iotib.net>2022-06-02 18:39:29 -0400
commitd1d13216310c7ebb23f99459e21905393d02b839 (patch)
treef70eee8aa27cf25e90e08aec1c930413df87c5c8 /src
parent2dd8b8b6e66aa7e47da42912b0ca07ed8d7f0c23 (diff)
downloadPong-C-0.2.tar.gz
Fixed some bugs and a segfault v0.2
Diffstat (limited to 'src')
-rw-r--r--src/main.c5
-rw-r--r--src/pong.h2
-rw-r--r--src/title.c10
3 files changed, 12 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index a638248..56fda9d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,7 +5,7 @@
 int Difficulty = 1;
 atomic_int Ticks = 0;
 bool GameGoing = true;
-char *VersionString;
+char VersionString[256];
 
 mtx_t AudioQueueBeingModified;
 
@@ -105,7 +105,7 @@ int main() {
 	SetWindowMinSize(1280, 720);
 
 	//Init Variables
-	strcpy(VersionString, "Version 0.2 - AEOLUS");
+	strncpy(VersionString, "Version 0.2 - AEOLUS", sizeof(VersionString));
 	
 	//Populate Audio Queue
 	for(unsigned int i = 0; i < 20; i++) {
@@ -137,6 +137,7 @@ int main() {
 	
 	GameGoing = false; // Make sure the game is going to end.
 	thrd_join(AudioThread, NULL);
+	thrd_join(InternalClock, NULL);
 	CloseWindow();
 	return(0);
 }
diff --git a/src/pong.h b/src/pong.h
index bb6e522..a425107 100644
--- a/src/pong.h
+++ b/src/pong.h
@@ -35,7 +35,7 @@ struct Balls {
 extern int Difficulty;
 extern bool GameGoing;
 extern atomic_int Ticks;
-extern char *VersionString;
+extern char VersionString[256];
 
 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 7617a7c..d53db5a 100644
--- a/src/title.c
+++ b/src/title.c
@@ -34,7 +34,13 @@ int title_screen() {
     Rectangle *Selected;
     Selected = &Versus;
     EnableCursor();
-    while(!WindowShouldClose() && TitleScreenGoing == true) {
+    while(TitleScreenGoing == true && GameGoing == true) {
+        
+        if (WindowShouldClose()) { //Quit Game if the window is closed.
+            GameGoing = false;
+            TitleScreenGoing = false;
+        }
+
         MainCamera.zoom = GetScreenHeight()/720.0f;
         Mouse.x = GetMouseX()/MainCamera.zoom;
         Mouse.y = GetMouseY()/MainCamera.zoom;
@@ -70,7 +76,7 @@ int title_screen() {
                 DrawText("Help", 20, 300, 48, WHITE);
                 DrawText("Exit", 20, 350, 48, WHITE);
             EndMode2D();
-            DrawText(VersionString, GetScreenWidth()-200, GetScreenHeight()-32, 32, GREEN);
+            DrawText(VersionString, GetScreenWidth()-400, GetScreenHeight()-32, 32, GREEN);
         EndDrawing();
     }
     return -1;