From d1d13216310c7ebb23f99459e21905393d02b839 Mon Sep 17 00:00:00 2001 From: Charadon Date: Thu, 2 Jun 2022 18:39:29 -0400 Subject: Fixed some bugs and a segfault --- src/main.c | 5 +++-- src/pong.h | 2 +- src/title.c | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') 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; -- cgit 1.4.1-2-gfad0