about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-06-01 20:21:10 -0400
committerCharadon <dev@iotib.net>2022-06-01 20:21:10 -0400
commit3f0c12dbea2cc070888f0db9102c12d0af6f2e90 (patch)
tree6857274c7a7df90c348e6763bd5fd4910bfdb809 /src
parent01a21af4c041c6f3133b4202ca35c156ffb00f32 (diff)
downloadPong-C-3f0c12dbea2cc070888f0db9102c12d0af6f2e90.tar.gz
Flatpak support
Diffstat (limited to 'src')
-rw-r--r--src/ball.c4
-rw-r--r--src/enemy.c2
-rwxr-xr-x[-rw-r--r--]src/launch.sh5
-rw-r--r--src/main.c25
-rw-r--r--src/sounds.h2
5 files changed, 29 insertions, 9 deletions
diff --git a/src/ball.c b/src/ball.c
index 7a9e7cb..95cc0c5 100644
--- a/src/ball.c
+++ b/src/ball.c
@@ -24,7 +24,7 @@ void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerSc
         if (Ball->Speed != 40) {
 		    Ball->Angle = GetRandomValue(-10, 10);
         } else {
-            Ball->Angle = GetRandomValue(-20, 20);
+            Ball->Angle = GetRandomValue(-30, 30);
         }
         play_audio(0);
 	}
@@ -65,4 +65,4 @@ void ball(Rectangle *Player, Rectangle *Enemy, struct Balls *Ball, int *PlayerSc
 	}
 
 	return;
-}
\ No newline at end of file
+}
diff --git a/src/enemy.c b/src/enemy.c
index e5e0a2b..5350770 100644
--- a/src/enemy.c
+++ b/src/enemy.c
@@ -34,4 +34,4 @@ void enemy(struct Players *Enemy, struct Balls ball) {
 	Enemy->HitBox.y = Enemy->Y;
 	Enemy->BallDetector.y = Enemy->Y+80;
 	return;
-}
\ No newline at end of file
+}
diff --git a/src/launch.sh b/src/launch.sh
index 7449fcb..1312ef3 100644..100755
--- a/src/launch.sh
+++ b/src/launch.sh
@@ -1,5 +1,4 @@
 #!/bin/sh
 # This file is only for flatpak.
-
-cd /app/Pong
-./pong $@
\ No newline at end of file
+DIRECTORY="$(dirname $0)"
+cd $DIRECTORY/../Pong && ./pong $@
\ No newline at end of file
diff --git a/src/main.c b/src/main.c
index 9339b92..de4dcb0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -2,6 +2,7 @@
 #include "sounds.h"
 #include <raylib.h>
 #include <setjmp.h>
+#include <threads.h>
 
 
 int Difficulty = 1;
@@ -103,7 +104,7 @@ int main() {
 	MainCamera.offset = (Vector2){0, 0};
 	MainCamera.rotation = 0;
 	//Populate Audio Queue
-	for(unsigned int i = 0; i < sizeof(AudioQueue); i++) {
+	for(unsigned int i = 0; i < 20; i++) {
 		AudioQueue[i] = -1;
 	}
 	mtx_init(&AudioQueueBeingModified, mtx_plain);
@@ -158,13 +159,34 @@ int main() {
 		MainCamera.offset = (Vector2){GetScreenWidth()/2.0f, GetScreenHeight()/2.0f};
 		MainCamera.target = (Vector2){1280/2.0f, 720/2.0f};
 
+
+		// Who won?
 		if (Enemy.Score >= 5) {
+			StopSoundMulti();
 			play_audio(MUSIC_DEFEAT);
+			while(!IsKeyDown(KEY_SPACE)) {
+				BeginDrawing();
+					EnableCursor();
+					ClearBackground(BLACK);
+					DrawText("You Lose.", 0, 0, 128, RED);
+					DrawText("Press space to return to title screen.", 0, 128, 24, WHITE);
+				EndDrawing();
+			}
 			longjmp(RestartGame, 0);
 		} else if (Player.Score >= 5) {
+			StopSoundMulti();
 			play_audio(MUSIC_VICTORY);
+			while(!IsKeyDown(KEY_SPACE)) {
+				BeginDrawing();
+					EnableCursor();
+					ClearBackground(BLACK);
+					DrawText("You Win!", 0, 0, 128, BLUE);
+					DrawText("Press space to return to title screen.", 0, 128, 24, WHITE);
+				EndDrawing();
+			}
 			longjmp(RestartGame, 0);
 		}
+
 		//Controls
 		if(IsKeyDown(KEY_UP)) {
 			Player.Y -= 10;
@@ -201,7 +223,6 @@ int main() {
 		//Turn Scores into strings.
 		snprintf(PlayerScore, 50, "Player: %d", Player.Score);
 		snprintf(EnemyScore, 50, "Enemy: %d", Enemy.Score);
-		printf("%f\n", Enemy.Y);
 		
 		BeginDrawing();
 			ClearBackground(BLACK);
diff --git a/src/sounds.h b/src/sounds.h
index 75a2455..0418c9c 100644
--- a/src/sounds.h
+++ b/src/sounds.h
@@ -7,4 +7,4 @@ const int MUSIC_VICTORY = 2;
 const int MUSIC_TITLE = 3;
 const int STOP_ALL_SOUNDS = 99;
 
-#endif
\ No newline at end of file
+#endif