diff options
-rw-r--r-- | meson.build | 2 | ||||
-rw-r--r-- | net.iotib.Pong.yml | 2 | ||||
-rw-r--r-- | src/main.c | 9 | ||||
-rw-r--r-- | src/marathon.c | 12 | ||||
-rw-r--r-- | src/pong.h | 2 | ||||
-rw-r--r-- | src/title.c | 3 | ||||
-rw-r--r-- | src/versus.c | 13 |
7 files changed, 33 insertions, 10 deletions
diff --git a/meson.build b/meson.build index 438bfa8..a8bd4ae 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('Pong', 'c', license : 'GPL-3.0-only', version : '0.1', default_options : ['warning_level=3', 'werror=true', 'optimization=g', 'c_std=c11', 'prefix=/opt']) +project('Pong', 'c', license : 'GPL-3.0-only', version : '0.2', default_options : ['warning_level=3', 'werror=true', 'optimization=g', 'c_std=c11', 'prefix=/opt']) add_project_link_arguments('../raylib/libraylib.a', '-lm', '-ldl', '-lrt', language : 'c') fs = import('fs') diff --git a/net.iotib.Pong.yml b/net.iotib.Pong.yml index 9937fe0..b057db3 100644 --- a/net.iotib.Pong.yml +++ b/net.iotib.Pong.yml @@ -1,5 +1,5 @@ app-id: net.iotib.Pong -branch: '0.1' +branch: '0.2' appdata-license: 'GPL-3.0-only' runtime: org.freedesktop.Platform runtime-version: '21.08' 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) { |