about summary refs log tree commit diff stats
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
parent01a21af4c041c6f3133b4202ca35c156ffb00f32 (diff)
downloadPong-C-3f0c12dbea2cc070888f0db9102c12d0af6f2e90.tar.gz
Flatpak support
-rw-r--r--meson.build11
-rw-r--r--meson_options.txt1
-rw-r--r--net.iotib.Pong.yml12
-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
8 files changed, 46 insertions, 16 deletions
diff --git a/meson.build b/meson.build
index 5bac36b..37b6eb1 100644
--- a/meson.build
+++ b/meson.build
@@ -14,10 +14,19 @@ if fs.exists('raylib/libraylib.a') == true
 else
     error('raylib failed to compile. Check meson-logs to see what went wrong.')
 endif
+
+Raylib_Include = include_directories('raylib/src')
+
+# Install launcher if flatpak
+if get_option('build_flatpak') == true
+    install_data('src/launch.sh', install_dir : 'bin')
+endif
+
 X11_Dep = dependency('x11')
 Threads_Dep = dependency('threads')
 GL_Dep = dependency('gl')
 
 Sources = ['src/main.c', 'src/enemy.c', 'src/ball.c', 'src/title.c']
 
-executable('pong', Sources, dependencies : [X11_Dep, Threads_Dep, GL_Dep])
\ No newline at end of file
+executable('pong', Sources, dependencies : [X11_Dep, Threads_Dep, GL_Dep], install : true, install_dir : 'Pong', include_directories : Raylib_Include)
+install_subdir('resources', install_dir : 'Pong')
\ No newline at end of file
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..4bcef13
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('build_flatpak', type : 'boolean', value : false)
\ No newline at end of file
diff --git a/net.iotib.Pong.yml b/net.iotib.Pong.yml
index 60ae3b8..9937fe0 100644
--- a/net.iotib.Pong.yml
+++ b/net.iotib.Pong.yml
@@ -7,14 +7,14 @@ sdk: org.freedesktop.Sdk
 command: launch.sh
 modules:
   - name: Pong
-    buildsystem: simple
-    build-commands:
-      - make clean
-      - make
-      - make install_flatpak
+    buildsystem: meson
+    config-opts:
+      - -Dbuild_flatpak=true
     sources:
       - type: file
-        path: Makefile
+        path: meson.build
+      - type: file
+        path: meson_options.txt
       - type: dir
         path: src
         dest: src
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