]> git.mcshandy.xyz Git - assteroids/commitdiff
Pause menu
authorAynRandDuran <lpj1496@gmail.com>
Thu, 15 Jul 2021 03:38:02 +0000 (23:38 -0400)
committerAynRandDuran <lpj1496@gmail.com>
Thu, 15 Jul 2021 03:38:02 +0000 (23:38 -0400)
assteroids.h
game.cpp
instructions.txt [new file with mode: 0644]

index 2657142988464a2316fa4f4f8fa27b0a663fb8e9..252cfb12ebc0a8ee5db806f95f616d1ceec56346 100644 (file)
@@ -10,7 +10,7 @@
 
 Sound sfx_music;
 Sound sfx_shoot;
-
+bool paused = false;
 int scrW = 800;
 int scrH = 650;
 Color Space = {21, 0, 26};
index b7bf5eb3acfb0365e3794d6a12fc964c3aa32b43..286130d52bcc28516241891b60ccfb908855c148 100644 (file)
--- a/game.cpp
+++ b/game.cpp
@@ -4,6 +4,8 @@
 #include "powerups.hpp"
 #include "vectormath.hpp"
 
+void show_instructions();
+
 Vector2 flatten(Vector4 pV){
     Vector2 stan = {pV.x, pV.y};
     return stan;
@@ -198,6 +200,7 @@ int main(void) {
     asteroids = (Vector4*)malloc(sizeof(Vector4)*MAX_ASTEROIDS);
     bullets = (Vector4*)malloc(sizeof(Vector4)*MAX_BULLETS);
     dead_ship = (Vector4*)malloc(sizeof(Vector4) * SHIP_DEBRIS);
+    paused = true;
 
     srand(time(NULL));
     InitWindow(scrW, scrH, "Assteroids Raylib");
@@ -208,6 +211,16 @@ int main(void) {
         BeginDrawing();
         ClearBackground(Space);
 
+        if(IsKeyPressed('H')) {
+            paused = !paused;
+        }
+        if(paused) {
+            show_instructions();
+            PauseSound(sfx_music);
+            EndDrawing();
+            continue;
+        }
+
         if((IsKeyDown('J') || IsKeyDown(KEY_LEFT)) && ship_alive) {
             spin_ship(-4);
         }
@@ -426,3 +439,14 @@ void update_bomb() {
         memset(&bomb_proj, 0, sizeof(Vector4));
     }
 }
+
+void show_instructions() {
+    DrawText("I/UP : START", (scrW/2)-(MeasureText("I/UP : START", 32)/2), (scrH/2)-256, 32, RED);
+    DrawText("J/LEFT : TURN PORT", (scrW/2)-(MeasureText("J/LEFT : TURN PORT", 32)/2), (scrH/2)-206, 32, RED);
+    DrawText("L/RIGHT : TURN STARBOARD", (scrW/2)-(MeasureText("L/RIGHT : TURN STARBOARD", 32)/2), (scrH/2)-156, 32, RED);
+    DrawText("S : SHOOT", (scrW/2)-(MeasureText("S : SHOOT", 32)/2), (scrH/2)-106, 32, RED);
+    DrawText("R : RESPAWN", (scrW/2)-(MeasureText("R : RESPAWN", 32)/2), (scrH/2)-56, 32, RED);
+    DrawText("A : WORMHOLE", (scrW/2)-(MeasureText("A : WORMHOLE", 32)/2), (scrH/2)-6, 32, RED);
+    DrawText("H : UN/PAUSE", (scrW/2)-(MeasureText("H : UN/PAUSE", 32)/2), (scrH/2)+50, 32, RED);
+    
+}
diff --git a/instructions.txt b/instructions.txt
new file mode 100644 (file)
index 0000000..e8e47fd
--- /dev/null
@@ -0,0 +1,10 @@
+
+Arrow keys/JIKL to move
+move forward to start
+R to restart after death
+S to shoot
+A to launch a wormhole when armed
+Shields last 9 seconds
+Shotgun pickup is good for 6 shots
+
+Ensure included WAV files are in the same directory as your executable