about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-09-11 15:44:04 -0400
committerCharadon <dev@iotib.net>2022-09-11 15:44:04 -0400
commit488823e80dfbacb253842690d78b666f0bc0454d (patch)
tree4b3502a33c48cc7529cfd6f21369685485501369
parent771896a49431e780e6f28c39d723113420fa56dc (diff)
downloadPong-C-488823e80dfbacb253842690d78b666f0bc0454d.tar.gz
Fixed flatpak support
-rw-r--r--.gitignore1
-rwxr-xr-xbuild-flatpak.sh14
-rwxr-xr-xclean.sh12
-rw-r--r--docs/credits.html15
-rw-r--r--flatpak.config4
-rwxr-xr-xinstall.sh18
-rw-r--r--net.iotib.Pong.yml29
-rw-r--r--src/Pong.desktop10
-rw-r--r--src/flatpak/flatpak_launch.sh4
-rw-r--r--src/flatpak/gc-8.2.2.tar.gzbin0 -> 1200115 bytes
-rw-r--r--src/flatpak/libatomic_ops-7.6.14.tar.gzbin0 -> 500006 bytes
-rw-r--r--src/main.c2
-rw-r--r--src/marathon.c1
-rw-r--r--src/title.c74
-rw-r--r--tup-generate.vardictbin0 -> 88 bytes
15 files changed, 126 insertions, 58 deletions
diff --git a/.gitignore b/.gitignore
index 7a1d835..662ec83 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,3 +11,4 @@ build-dir/
 bin/
 obj/
 .depend
+pong.vimsession
diff --git a/build-flatpak.sh b/build-flatpak.sh
new file mode 100755
index 0000000..e9a77b0
--- /dev/null
+++ b/build-flatpak.sh
@@ -0,0 +1,14 @@
+#! /bin/sh -e
+export tup_vardict="/run/media/conglomerate/productive/programming/c/Pong-C/tup-generate.vardict"
+mkdir -p "build"
+mkdir -p "build/bin"
+mkdir -p "build/obj"
+(cc `pkg-config --cflags raylib` `pkg-config --cflags glfw3` `pkg-config --cflags glu` `pkg-config --cflags gl` `pkg-config --cflags sdl2` `pkg-config --cflags SDL2_mixer` `pkg-config --cflags bdw-gc` -Isrc/ -std=gnu99 -Wall -O3 -g -ggdb -c src/ball.c -o ./build/obj/ball.o)
+(cc `pkg-config --cflags raylib` `pkg-config --cflags glfw3` `pkg-config --cflags glu` `pkg-config --cflags gl` `pkg-config --cflags sdl2` `pkg-config --cflags SDL2_mixer` `pkg-config --cflags bdw-gc` -Isrc/ -std=gnu99 -Wall -O3 -g -ggdb -c src/controls.c -o ./build/obj/controls.o)
+(cc `pkg-config --cflags raylib` `pkg-config --cflags glfw3` `pkg-config --cflags glu` `pkg-config --cflags gl` `pkg-config --cflags sdl2` `pkg-config --cflags SDL2_mixer` `pkg-config --cflags bdw-gc` -Isrc/ -std=gnu99 -Wall -O3 -g -ggdb -c src/enemy.c -o ./build/obj/enemy.o)
+(cc `pkg-config --cflags raylib` `pkg-config --cflags glfw3` `pkg-config --cflags glu` `pkg-config --cflags gl` `pkg-config --cflags sdl2` `pkg-config --cflags SDL2_mixer` `pkg-config --cflags bdw-gc` -Isrc/ -std=gnu99 -Wall -O3 -g -ggdb -c src/main.c -o ./build/obj/main.o)
+(cc `pkg-config --cflags raylib` `pkg-config --cflags glfw3` `pkg-config --cflags glu` `pkg-config --cflags gl` `pkg-config --cflags sdl2` `pkg-config --cflags SDL2_mixer` `pkg-config --cflags bdw-gc` -Isrc/ -std=gnu99 -Wall -O3 -g -ggdb -c src/marathon.c -o ./build/obj/marathon.o)
+(cc `pkg-config --cflags raylib` `pkg-config --cflags glfw3` `pkg-config --cflags glu` `pkg-config --cflags gl` `pkg-config --cflags sdl2` `pkg-config --cflags SDL2_mixer` `pkg-config --cflags bdw-gc` -Isrc/ -std=gnu99 -Wall -O3 -g -ggdb -c src/pause.c -o ./build/obj/pause.o)
+(cc `pkg-config --cflags raylib` `pkg-config --cflags glfw3` `pkg-config --cflags glu` `pkg-config --cflags gl` `pkg-config --cflags sdl2` `pkg-config --cflags SDL2_mixer` `pkg-config --cflags bdw-gc` -Isrc/ -std=gnu99 -Wall -O3 -g -ggdb -c src/title.c -o ./build/obj/title.o)
+(cc `pkg-config --cflags raylib` `pkg-config --cflags glfw3` `pkg-config --cflags glu` `pkg-config --cflags gl` `pkg-config --cflags sdl2` `pkg-config --cflags SDL2_mixer` `pkg-config --cflags bdw-gc` -Isrc/ -std=gnu99 -Wall -O3 -g -ggdb -c src/versus.c -o ./build/obj/versus.o)
+(cc ./build/obj/ball.o ./build/obj/controls.o ./build/obj/enemy.o ./build/obj/main.o ./build/obj/marathon.o ./build/obj/pause.o ./build/obj/title.o ./build/obj/versus.o -o ./build/bin/Pong `pkg-config --libs raylib` `pkg-config --libs glfw3` `pkg-config --libs glu` `pkg-config --libs gl` `pkg-config --libs sdl2` `pkg-config --libs SDL2_mixer` `pkg-config --libs bdw-gc`)
diff --git a/clean.sh b/clean.sh
index 39683ec..6b09e59 100755
--- a/clean.sh
+++ b/clean.sh
@@ -1,7 +1,15 @@
 #!/bin/sh
-set -eu
+set -e
 
-. ./tup.config
+# Check if another config is being used.
+if [ -z $TUP_CONFIG ];
+then
+	. ./tup.config
+else
+	. ./$TUP_CONFIG
+fi
+
+set -u
 
 echo "Cleaning Project..."
 set -x
diff --git a/docs/credits.html b/docs/credits.html
new file mode 100644
index 0000000..79bb12c
--- /dev/null
+++ b/docs/credits.html
@@ -0,0 +1,15 @@
+<html>
+	<h1>CREDITS:</h1>
+	<hr />
+	<table border="2px">
+		<tr>
+			<th>Author</th><th>Asset</th><th>License</th><th>Link</th>
+		</tr>
+		<tr>
+			<th><a href="https://fosstodon.org/web/@allinone0">2xYz</a></th>
+			<th>Game Icon (<a href="../resources/icon.svg">resources/icon.svg</a>)</th>
+			<th>Creative Commons Attribution (<a href="https://fosstodon.org/@allinone0/108981413047928142">Source</a> | <a href="https://archive.ph/fLYSK">Archive</a>)</th>
+			<th><a href="https://fosstodon.org/@allinone0/108981315839693129">Original</a> | <a href="https://archive.ph/XSuqe">Archive</a></th>
+		</tr>
+	</table>
+</html>
diff --git a/flatpak.config b/flatpak.config
new file mode 100644
index 0000000..fcf46d7
--- /dev/null
+++ b/flatpak.config
@@ -0,0 +1,4 @@
+CONFIG_CC=cc
+CONFIG_FLATPAK=true
+CONFIG_INSTALL_PREFIX=/app/games/pong
+CONFIG_BUILD_DIR=./build
diff --git a/install.sh b/install.sh
index 40d2c2b..83567f1 100755
--- a/install.sh
+++ b/install.sh
@@ -1,7 +1,15 @@
 #!/bin/sh
-set -eu
+set -e
 
-source ./tup.config
+# Check if another config is being sourced.
+if [ -z $TUP_CONFIG ];
+then
+	. ./tup.config
+else
+	. ./$TUP_CONFIG
+fi
+
+set -u
 
 echo "Installing Project."
 set -x
@@ -9,5 +17,11 @@ mkdir -p $CONFIG_INSTALL_PREFIX
 cp -r ./resources $CONFIG_INSTALL_PREFIX/resources
 cp -r ./docs $CONFIG_INSTALL_PREFIX/docs
 install -m755 $CONFIG_BUILD_DIR/bin/Pong* $CONFIG_INSTALL_PREFIX/
+
+if [ "$CONFIG_FLATPAK" = "true" ];
+then
+	install -Dm755 src/flatpak/flatpak_launch.sh /app/bin/flatpak_launch.sh
+	install -Dm644 src/Pong.desktop /app/share/applications/net.iotib.Pong.desktop
+fi
 set +x
 echo "Done Installing."
diff --git a/net.iotib.Pong.yml b/net.iotib.Pong.yml
index c39290a..23787a6 100644
--- a/net.iotib.Pong.yml
+++ b/net.iotib.Pong.yml
@@ -9,33 +9,34 @@ modules:
   - name: Pong
     buildsystem: simple
     build-commands:
-      - mkdir -pv /app/Pong
-      - mkdir -pv /app/bin
-      - mkdir -pv /app
-      - mkdir -pv /app/lib
-      - mkdir -pv /app/include
       - tar -xvf src/flatpak/raylib-4.0.0.tar.gz
-      - cmake -B raylib-4.0.0/build -DUSE_EXTERNAL_GLFW=OFF -DBUILD_SHARED_LIBS=ON -DBUILD_EXAMPLES=OFF -DPLATFORM=Desktop -DCMAKE_INSTALL_PREFIX=/app raylib-4.0.0
-      - make -C raylib-4.0.0/build
-      - make -C raylib-4.0.0/build install
-      - make
-      - install -Dvm755 bin/*/Pong /app/Pong/pong
-      - install -Dvm755 src/flatpak/flatpak_launch.sh /app/bin/flatpak_launch.sh
-      - cp -rv resources /app/Pong/
+      - cd raylib-4.0.0 && mkdir build && cd build && cmake -DBUILD_EXAMPLES=OFF -DUSE_EXTERNAL_GLFW=OFF -DBUILD_SHARED_LIBS=ON -DGRAPHICS="GRAPHICS_API_OPENGL_ES2" -DCMAKE_INSTALL_PREFIX=/app -G Ninja .. && ninja && ninja install
+      - tar -xvf src/flatpak/libatomic_ops-7.6.14.tar.gz
+      - cd libatomic_ops-7.6.14 && ./configure --prefix=/app && make && make install
+      - tar -xvf src/flatpak/gc-8.2.2.tar.gz
+      - cd gc-8.2.2/build && cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/app .. && ninja && ninja install
+      - ./build-flatpak.sh
+      - bash -c "TUP_CONFIG=./flatpak.config ./install.sh"
     sources:
       - type: file
-        path: Makefile
+        path: install.sh
       - type: file
-        path: Pong.make
+        path: flatpak.config
+      - type: file
+        path: build-flatpak.sh
       - type: dir
         path: src
         dest: src
       - type: dir
         path: resources
         dest: resources
+      - type: dir
+        path: docs
+        dest: docs
 finish-args:
   - --socket=x11
   - --device=dri
+  - --device=all
   - --share=ipc
   - --socket=pulseaudio
   - --socket=wayland
diff --git a/src/Pong.desktop b/src/Pong.desktop
new file mode 100644
index 0000000..a4dcd81
--- /dev/null
+++ b/src/Pong.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Type=Application
+NoDisplay=false
+Terminal=false
+Exec=/app/bin/flatpak_launch.sh
+Icon=
+Name=Pong
+Comment=A portable pong clone made in C
+Categories=Game
+X-Desktop-File-Install-Version=0.26
diff --git a/src/flatpak/flatpak_launch.sh b/src/flatpak/flatpak_launch.sh
index 959858f..41961ba 100644
--- a/src/flatpak/flatpak_launch.sh
+++ b/src/flatpak/flatpak_launch.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
 # This file is only for flatpak.
 DIRECTORY="$(dirname "$0")"
-RUN_COMMAND='./pong $@'
-cd "$DIRECTORY"/../Pong && $RUN_COMMAND
\ No newline at end of file
+RUN_COMMAND='./Pong $@'
+cd "$DIRECTORY"/../games/pong && $RUN_COMMAND
diff --git a/src/flatpak/gc-8.2.2.tar.gz b/src/flatpak/gc-8.2.2.tar.gz
new file mode 100644
index 0000000..9a404d1
--- /dev/null
+++ b/src/flatpak/gc-8.2.2.tar.gz
Binary files differdiff --git a/src/flatpak/libatomic_ops-7.6.14.tar.gz b/src/flatpak/libatomic_ops-7.6.14.tar.gz
new file mode 100644
index 0000000..3c91ff1
--- /dev/null
+++ b/src/flatpak/libatomic_ops-7.6.14.tar.gz
Binary files differdiff --git a/src/main.c b/src/main.c
index f556f98..31e2ab0 100644
--- a/src/main.c
+++ b/src/main.c
@@ -146,6 +146,8 @@ bool play_audio(int SoundEffect) {
 }
 
 int main(int argc, char *argv[]) {
+	/* Credits acknowledgements */
+	fprintf(stdout, "Game Icon (resources/icon.svg) by 2xYz is licensed under Creative Commons. Check docs/credits.html for more info.\n");
 	/* Raylib Init */
 	SDL_Init(SDL_INIT_AUDIO);
 	InitWindow(1280, 720, "Pong");
diff --git a/src/marathon.c b/src/marathon.c
index c0507e2..70484b6 100644
--- a/src/marathon.c
+++ b/src/marathon.c
@@ -1,5 +1,4 @@
 #include "pong.h"
-#include <raylib.h>
 
 void leaderboard_record(int Score) {
     bool LeaderBoardGoing = true;
diff --git a/src/title.c b/src/title.c
index 1209193..d729f0a 100644
--- a/src/title.c
+++ b/src/title.c
@@ -146,45 +146,45 @@ static void score_screen(Camera2D *MainCamera) {
         BeginDrawing();
             ClearBackground(BLACK);
             BeginMode2D(*MainCamera);
-            DrawRectangle(0, 0, 1280, 720, (Color){20, 20, 20, 255});
-		/* Scores */
-		int a = 0;
-		int i = 0;
-            	for (i = 1+(10*Page); i <= 10+(10*Page); i++, a++) {
-	            if(Scores[i-1]->Name[0] != ' ') {
-            	    	DrawText(TextFormat("%d. %s: %d", i, Scores[i-1]->Name, Scores[i-1]->Score), 460, 60+(50*a), 48, WHITE);
-                	} else {
-                		EndOfPages = true;
-                	}
-            	}
-		/* Page Buttons */
-		if(CheckCollisionRecs(MouseCursor, PrevPage) && Page > 0) {
-			DrawRectangleRec(PrevPage, RED);
-			if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
-				if(Page > 0) {
-					Page--;
+	            DrawRectangle(0, 0, 1280, 720, (Color){20, 20, 20, 255});
+				/* Scores */
+				int a = 0;
+				int i = 0;
+	           	for (i = 1+(10*Page); i <= 10+(10*Page); i++, a++) {
+		            if(Scores[i-1]->Name[0] != ' ') {
+	            	   	DrawText(TextFormat("%d. %s: %d", i, Scores[i-1]->Name, Scores[i-1]->Score), 460, 60+(50*a), 48, WHITE);
+	                } else {
+	                	EndOfPages = true;
+	                }
+	           	}
+				/* Page Buttons */
+				if(CheckCollisionRecs(MouseCursor, PrevPage) && Page > 0) {
+					DrawRectangleRec(PrevPage, RED);
+					if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
+						if(Page > 0) {
+							Page--;
+						}
+					}
+				} else if(CheckCollisionRecs(MouseCursor, NextPage) && EndOfPages == false) {
+					DrawRectangleRec(NextPage, RED);
+					if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
+						if(EndOfPages == false) {
+							Page++;
+						}
+					}
 				}
-			}
-		} else if(CheckCollisionRecs(MouseCursor, NextPage) && EndOfPages == false) {
-			DrawRectangleRec(NextPage, RED);
-			if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
-				if(EndOfPages == false) {
-					Page++;
+	            DrawText("<--", 5, 720-50, 48, WHITE);
+	            DrawText("-->", 1280-70, 720-50, 48, WHITE);
+				/* Exit Button */
+				if(CheckCollisionRecs(MouseCursor, (Rectangle){0,0,42,120})) {
+					DrawRectangle(0, 0, 42, 120, RED);
+					if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
+						LookingAtScores = false;
+					}
 				}
-			}
-		}
-                DrawText("<--", 5, 720-50, 48, WHITE);
-                DrawText("-->", 1280-70, 720-50, 48, WHITE);
-		/* Exit Button */
-		if(CheckCollisionRecs(MouseCursor, (Rectangle){0,0,42,120})) {
-			DrawRectangle(0, 0, 42, 120, RED);
-			if(IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
-				LookingAtScores = false;
-			}
-		}
-		DrawText("<", 0, 0, 128, WHITE);
-		/* Cursor */
-                DrawTexture(MouseCursorSprite, MouseCursor.x, MouseCursor.y, WHITE);
+				DrawText("<", 0, 0, 128, WHITE);
+				/* Cursor */
+            	DrawTexture(MouseCursorSprite, MouseCursor.x, MouseCursor.y, WHITE);
             EndMode2D();
         EndDrawing();
     }
diff --git a/tup-generate.vardict b/tup-generate.vardict
new file mode 100644
index 0000000..55356ad
--- /dev/null
+++ b/tup-generate.vardict
Binary files differ