diff options
author | Charadon <dev@iotib.net> | 2022-06-01 17:34:51 -0400 |
---|---|---|
committer | Charadon <dev@iotib.net> | 2022-06-01 17:34:51 -0400 |
commit | 01a21af4c041c6f3133b4202ca35c156ffb00f32 (patch) | |
tree | 7a118b37c09e744325cf3740a62e2857ae839ea0 | |
parent | 081187244a0f69a0043d15dd7ad2cf5f127c60be (diff) | |
download | Pong-C-01a21af4c041c6f3133b4202ca35c156ffb00f32.tar.gz |
Migrate to meson
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | .gitlab-ci.yml | 2 | ||||
-rw-r--r-- | Makefile | 34 | ||||
-rw-r--r-- | meson.build | 23 | ||||
-rw-r--r-- | src/main.c | 9 | ||||
-rw-r--r-- | src/pong.h | 2 | ||||
-rw-r--r-- | src/title.c | 2 |
7 files changed, 34 insertions, 40 deletions
diff --git a/.gitignore b/.gitignore index 669871f..3fd4164 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ app/ +build/ +.cache/ *.o pong .flatpak-builder diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index c3789a3..7cc4fa0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -22,8 +22,6 @@ build-job: # This job runs in the build stage, which runs first. script: - apk add flatpak - apk add flatpak-builder - - chmod u+s /usr/bin/bwrap - - sysctl kernel.unprivileged_userns_clone - flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - flatpak install -y org.freedesktop.Sdk/x86_64/21.08 - flatpak install -y org.freedesktop.Platform/x86_64/21.08 diff --git a/Makefile b/Makefile deleted file mode 100644 index 7a06e58..0000000 --- a/Makefile +++ /dev/null @@ -1,34 +0,0 @@ -CC := gcc -CFLAGS = -Og -Wall -std=c11 -Isrc/ -Iraylib/src -LDFLAGS = -lGL -lm -lpthread -ldl -lrt -lX11 - -all: build_deps build pong - -build_deps: - cd raylib/src && $(MAKE) PLATFORM=PLATFORM_DESKTOP RAYLIB_BUILD_MODE=RELEASE USE_EXTERNAL_GLFW=FALSE - -build: src/main.c src/enemy.c src/ball.c src/title.c - $(CC) $(CFLAGS) $(PKG_CONF_CFLAGS) -c $? - -pong: main.o enemy.o ball.o title.o - $(CC) $? -o $@ raylib/libraylib.a $(LDFLAGS) - -install: - mkdir -p app - install -Dm755 ./pong app/pong - cp -r resources app/resources - -install_flatpak: - mkdir -p /app/Pong - install -Dm755 ./pong /app/Pong/pong - cp -r resources/ /app/Pong/resources - mkdir -p /app/bin - install -Dm755 src/launch.sh /app/bin/launch.sh - -clean: - rm -fv *.o - rm -fv pong - rm -rf .flatpak-builder/ - rm -rf flatpak/ - rm -rf *.flatpak - cd raylib/src && $(MAKE) clean diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..5bac36b --- /dev/null +++ b/meson.build @@ -0,0 +1,23 @@ +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']) +add_project_link_arguments('../raylib/libraylib.a', '-lm', '-ldl', '-lrt', language : 'c') +fs = import('fs') + + +message('Cleaning raylib...') +# First clean up +run_command('make', '-C', 'raylib/src', 'clean', capture : true, check : true) +message('Building raylib...') +# Then Build +run_command('make', '-C', 'raylib/src', 'PLATFORM=PLATFORM_DESKTOP', 'RAYLIB_BUILD_MODE=RELEASE', capture : true, check : true) +if fs.exists('raylib/libraylib.a') == true + message('raylib successfully compiled.') +else + error('raylib failed to compile. Check meson-logs to see what went wrong.') +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 diff --git a/src/main.c b/src/main.c index 89422ba..9339b92 100644 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,6 @@ #include "pong.h" #include "sounds.h" +#include <raylib.h> #include <setjmp.h> @@ -67,7 +68,7 @@ int audio() { } bool play_audio(int SoundEffect) { - int i; + unsigned int i; while(mtx_trylock(&AudioQueueBeingModified) == thrd_busy); for(i = 1; i != 20; i++) { if (AudioQueue[i-1] == -1) { @@ -94,6 +95,7 @@ int main() { SetWindowIcon(Icon); SetWindowState(FLAG_VSYNC_HINT); SetWindowState(FLAG_WINDOW_RESIZABLE); + SetWindowMinSize(1280, 720); //Initialize Variables Camera2D MainCamera; @@ -101,7 +103,7 @@ int main() { MainCamera.offset = (Vector2){0, 0}; MainCamera.rotation = 0; //Populate Audio Queue - for(int i = 0; i < sizeof(AudioQueue); i++) { + for(unsigned int i = 0; i < sizeof(AudioQueue); i++) { AudioQueue[i] = -1; } mtx_init(&AudioQueueBeingModified, mtx_plain); @@ -153,6 +155,9 @@ int main() { while(!WindowShouldClose() && GameGoing == true) { MainCamera.zoom = GetScreenHeight()/720.0f; + MainCamera.offset = (Vector2){GetScreenWidth()/2.0f, GetScreenHeight()/2.0f}; + MainCamera.target = (Vector2){1280/2.0f, 720/2.0f}; + if (Enemy.Score >= 5) { play_audio(MUSIC_DEFEAT); longjmp(RestartGame, 0); diff --git a/src/pong.h b/src/pong.h index fff6065..70e9215 100644 --- a/src/pong.h +++ b/src/pong.h @@ -47,4 +47,4 @@ extern const int MUSIC_VICTORY; extern const int MUSIC_TITLE; extern const int STOP_ALL_SOUNDS; -#endif \ No newline at end of file +#endif diff --git a/src/title.c b/src/title.c index 806c0d0..1f2a51d 100644 --- a/src/title.c +++ b/src/title.c @@ -68,4 +68,4 @@ void title_screen() { EndDrawing(); } return; -} \ No newline at end of file +} |