From 6663682763d953ba20805fd6a15f79c06f4ac7f4 Mon Sep 17 00:00:00 2001 From: Charadon Date: Tue, 20 Sep 2022 10:56:11 -0400 Subject: Controller support for settings screen and some more build system stuff --- Tupfile.ini | 0 flatpak.config | 1 + install.sh | 5 +++-- net.iotib.Pong.metainfo.xml | 53 ++++++++++++++++++++++++++++++++++++++++++++ net.iotib.Pong.yml | 4 +++- src/title.c | 22 +++++++++++++++++- tup-generate.vardict | Bin 88 -> 0 bytes tup.config | 1 + 8 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 Tupfile.ini create mode 100644 net.iotib.Pong.metainfo.xml delete mode 100644 tup-generate.vardict diff --git a/Tupfile.ini b/Tupfile.ini new file mode 100644 index 0000000..e69de29 diff --git a/flatpak.config b/flatpak.config index fcf46d7..4d8fe6d 100644 --- a/flatpak.config +++ b/flatpak.config @@ -1,4 +1,5 @@ CONFIG_CC=cc +CONFIG_DEBUG=false CONFIG_FLATPAK=true CONFIG_INSTALL_PREFIX=/app/games/pong CONFIG_BUILD_DIR=./build diff --git a/install.sh b/install.sh index 3c8a612..08e74ee 100755 --- a/install.sh +++ b/install.sh @@ -14,14 +14,15 @@ set -u echo "Installing Project." set -x mkdir -p $CONFIG_INSTALL_PREFIX -cp -r ./resources $CONFIG_INSTALL_PREFIX/resources -cp -r ./docs $CONFIG_INSTALL_PREFIX/docs +cp -r ./resources $CONFIG_INSTALL_PREFIX/ +cp -r ./docs $CONFIG_INSTALL_PREFIX/ 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 + install -Dm644 net.iotib.Pong.metainfo.xml /app/share/appdata/net.iotib.Pong.metainfo.xml install -Dm644 resources/icon.svg /app/share/icons/hicolor/scalable/apps/net.iotib.Pong.svg fi set +x diff --git a/net.iotib.Pong.metainfo.xml b/net.iotib.Pong.metainfo.xml new file mode 100644 index 0000000..6b14cb3 --- /dev/null +++ b/net.iotib.Pong.metainfo.xml @@ -0,0 +1,53 @@ + + + + net.iotib.Pong + Pong + A pong clone made in C. + iotib + net.iotib.Pong.desktop + GFDL-1.3 + GPL-3.0-only + dev@iotib.net + +

This is a clone of Pong made in C for basically every operating system.

+

It supports:

+
    +
  1. Local Versus
  2. +
  3. Single Player Versus
  4. +
  5. Marathon w/ Scoreboard
  6. +
+
+ + + https://www.opencode.net/charadon/Pong-C/-/releases + + + https://www.opencode.net/charadon/Pong-C + https://www.opencode.net/charadon/Pong-C/-/issues + https://pong.iotib.net/ + https://pong.iotib.net/ + https://liberapay.com/Charadon/ + https://www.iotib.net/ + + Game + + + 128 + + + medium + 256 + + + pointing + keyboard + gamepad + + + + pong + pong clone + clone + +
diff --git a/net.iotib.Pong.yml b/net.iotib.Pong.yml index 23787a6..c24aa9b 100644 --- a/net.iotib.Pong.yml +++ b/net.iotib.Pong.yml @@ -2,7 +2,7 @@ app-id: net.iotib.Pong branch: '0.4' appdata-license: 'GPL-3.0-only' runtime: org.freedesktop.Platform -runtime-version: '21.08' +runtime-version: '22.08' sdk: org.freedesktop.Sdk command: flatpak_launch.sh modules: @@ -20,6 +20,8 @@ modules: sources: - type: file path: install.sh + - type: file + path: net.iotib.Pong.metainfo.xml - type: file path: flatpak.config - type: file diff --git a/src/title.c b/src/title.c index d16ff84..7594ed9 100644 --- a/src/title.c +++ b/src/title.c @@ -243,6 +243,8 @@ static void settings(Camera2D *MainCamera, Mix_Music *TitleScreenMusic) { Vector2 NewPosition = GetMousePosition(); Texture2D MouseCursorSprite = LoadTexture("resources/cursor.png"); bool MouseCursorIn = true; + bool OnBackButton = true; + int Choice = 0; while(SettingsGoing == true && GameGoing == true) { MainCamera->zoom = GetScreenHeight()/720.0f; @@ -263,6 +265,24 @@ static void settings(Camera2D *MainCamera, Mix_Music *TitleScreenMusic) { } } + int KeyPressed = player_controls_pressed(); + + switch(KeyPressed) { + case CONTROLLER_ACTIVATE: + if ( OnBackButton == true ) { + SettingsGoing = false; + } + OnBackButton = true; + Choice = 0; + break; + case CONTROLLER_UP: + --Choice; + break; + case CONTROLLER_DOWN: + ++Choice; + break; + } + if (IsKeyPressed(KEY_ESCAPE)) { EnableCursor(); MouseCursorIn = false; @@ -277,7 +297,7 @@ static void settings(Camera2D *MainCamera, Mix_Music *TitleScreenMusic) { BeginMode2D(*MainCamera); DrawRectangle(0, 0, 1280, 720, (Color){20, 20, 20, 255}); /* Back Button */ - if (CheckCollisionRecs(MouseCursor, BackButton)) { + if (CheckCollisionRecs(MouseCursor, BackButton) || OnBackButton == true) { DrawRectangleRec(BackButton, RED); if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { SettingsGoing = false; diff --git a/tup-generate.vardict b/tup-generate.vardict deleted file mode 100644 index 55356ad..0000000 Binary files a/tup-generate.vardict and /dev/null differ diff --git a/tup.config b/tup.config index 226a926..d3997b7 100644 --- a/tup.config +++ b/tup.config @@ -1,4 +1,5 @@ CONFIG_CC=cc +CONFIG_DEBUG=true CONFIG_FLATPAK=false CONFIG_INSTALL_PREFIX=./app CONFIG_BUILD_DIR=./build -- cgit 1.4.1-2-gfad0