about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCharadon <dev@iotib.net>2022-06-15 06:01:20 -0400
committerCharadon <dev@iotib.net>2022-06-15 06:01:20 -0400
commit283fb7c5502f3bd07094f25d0aec84d402cf656f (patch)
treeb007793a76b5b342ce191ddf8130d308cb642f70
parent65bb3b25d1016fa87da3893c4d9b43c3f30d328e (diff)
downloadPong-C-283fb7c5502f3bd07094f25d0aec84d402cf656f.tar.gz
Some work on non-mouse controls
-rw-r--r--net.iotib.Pong.yml4
-rw-r--r--src/main.c3
-rw-r--r--src/title.c38
3 files changed, 29 insertions, 16 deletions
diff --git a/net.iotib.Pong.yml b/net.iotib.Pong.yml
index d591ad7..c39290a 100644
--- a/net.iotib.Pong.yml
+++ b/net.iotib.Pong.yml
@@ -1,5 +1,5 @@
 app-id: net.iotib.Pong
-branch: '0.3'
+branch: '0.4'
 appdata-license: 'GPL-3.0-only'
 runtime: org.freedesktop.Platform
 runtime-version: '21.08'
@@ -38,4 +38,4 @@ finish-args:
   - --device=dri
   - --share=ipc
   - --socket=pulseaudio
-  - --socket=wayland
\ No newline at end of file
+  - --socket=wayland
diff --git a/src/main.c b/src/main.c
index 8eaba43..4a383f4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -46,6 +46,7 @@ void set_screen_mode() {
 	}
 	return;
 }
+
 double Started;
 static int internal_clock() {
 	static const double Framerate = 1.0/60.0f;
@@ -164,7 +165,7 @@ int main(int argc, char *argv[]) {
 	GlobalSettings.MusicVolume = 0;
 
 	//Init Variables
-	strncpy(VersionString, "Version 0.3 - Charon", sizeof(VersionString));
+	strncpy(VersionString, "Version 0.4 - APOLLO", sizeof(VersionString));
 	
 	//Populate Audio Queue
 	for(unsigned int i = 0; i < 20; i++) {
diff --git a/src/title.c b/src/title.c
index 9fe11cf..713b2c0 100644
--- a/src/title.c
+++ b/src/title.c
@@ -1,6 +1,5 @@
 #include "pong.h"
 #include <raylib.h>
-#include <stdio.h>
 
 struct LeaderboardEntries {
     int Score;
@@ -422,6 +421,18 @@ int title_screen() {
                 Mouse.x += OldPosition.x-NewPosition.x;
             }
         }
+
+		//Gamepad & Keyboard
+		if(IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_DOWN) || IsKeyPressed(KEY_S)) {
+			Choice++;
+		} else if(IsGamepadButtonPressed(0, GAMEPAD_BUTTON_LEFT_FACE_UP) || IsKeyPressed(KEY_W)) {
+			Choice--;
+		}
+		if(Choice > 5) {
+			Choice = 5;
+		} else if(Choice < 0) {
+			Choice = 0;
+		}
         
         if (IsKeyPressed(KEY_ESCAPE)) {
             EnableCursor();
@@ -431,31 +442,32 @@ int title_screen() {
             MouseCursorIn = true;
         }
 
-        if (CheckCollisionRecs(Mouse, Versus)) {
+        if (CheckCollisionRecs(Mouse, Versus) || Choice == 0) {
             Selected = &Versus;
-            Choice = 0;
-            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
+            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) || IsKeyPressed(KEY_SPACE) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) {
                 TitleScreenGoing = false;
+            	Choice = 0;
             }
-        } else if (CheckCollisionRecs(Mouse, Marathon)) {
+        } else if (CheckCollisionRecs(Mouse, Marathon) || Choice == 1) {
             Selected = &Marathon;
-            Choice = 1;
-            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
+            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) || IsKeyPressed(KEY_SPACE) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) {
                 TitleScreenGoing = false;
+            	Choice = 1;
             }
-        } else if (CheckCollisionRecs(Mouse, Settings)) {
+        } else if (CheckCollisionRecs(Mouse, Settings) || Choice == 2) {
             Selected = &Settings;
-        Choice = 0;
-            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
+            if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT) || IsKeyPressed(KEY_SPACE) || IsGamepadButtonPressed(0, GAMEPAD_BUTTON_RIGHT_FACE_DOWN)) {
                 settings(&MainCamera, TitleMusic);
+        		Choice = 2;
             }
-        } else if (CheckCollisionRecs(Mouse, Help)) {
+        } else if (CheckCollisionRecs(Mouse, Help) || Choice == 3) {
             Selected = &Help;
-        } else if (CheckCollisionRecs(Mouse, Exit)) {
+			Choice = 3;
+        } else if (CheckCollisionRecs(Mouse, Exit) || Choice == -1) {
             Selected = &Exit;
+			Choice = 4;
             if (IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) {
                 GameGoing = false;
-                Choice = -1;
             }
         }
         BeginDrawing();