]> git.mcshandy.xyz Git - assteroids/commitdiff
Statically link so it's shareable
authorAynRandDuran <lpj1496@gmail.com>
Sat, 17 Jul 2021 23:26:03 +0000 (19:26 -0400)
committerAynRandDuran <lpj1496@gmail.com>
Sat, 17 Jul 2021 23:26:03 +0000 (19:26 -0400)
Makefile
assteroids.h
game.cpp

index 1c7eab20a5bc56e78288e5f7297eda57b0dcf1ba..47bb147fd82162f93e38505cf5df6f1c0fe060ae 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
 LIBS = -lraylib -lgdi32 -lwinmm
 
 game: game.cpp
-       $(CXX) $@.cpp $(LIBS) -o $@ 
+       $(CXX) -static game.cpp $(LIBS) -o $@ 
index 34d30fdf83fe33ba00400c24c0158e29ea2abcfc..95341cd5dd77fd7850541a4dd6a3e5053fea73dc 100644 (file)
@@ -1,10 +1,8 @@
 #ifndef __ass
 #define __ass
-
 #include <raylib.h>
 #include <cstdio>
 #include <ctime>
-
 #define SFX_SHOOT_FILE "./shoot.wav"
 #define SFX_BGM_FILE "./music.wav"
 
@@ -74,5 +72,10 @@ int shotgun_kills  = 0;
 int deaths_avoided = 0;
 int time_alive     = 0;
 
+//getopts
+bool enable_fps = false; //fps counter off by default
+bool debug_nodie = false; //Perma-shield
+bool debug_shotgun = false; //Perma-shotgun
+bool debug_bomb = false; //Perma-bomb
 #endif //__ass
 
index 254d47e72cef0a8dce5bee471c15fc5808e3feae..10e7509dbb8f48366cdac8c2e27bb3bb5ca12635 100644 (file)
--- a/game.cpp
+++ b/game.cpp
@@ -1,5 +1,6 @@
 #include <cstring>
 #include <math.h>
+#include <unistd.h>
 #include "assteroids.h"
 #include "powerups.hpp"
 #include "vectormath.hpp"
@@ -189,7 +190,7 @@ void update_astrs() {
         }
 
         if(ship_collision(astr) && ship_alive){
-            if((active_powerups & GOD)) {
+            if((active_powerups & GOD) || debug_nodie) {
                 deaths_avoided++;
                 continue;
             }
@@ -199,7 +200,31 @@ void update_astrs() {
 
 }
 
-int main(void) {
+int main(int argc, char** argv) {
+    int opts;
+
+    while((opts = getopt(argc, argv, "fsgb")) != -1) {
+        switch(opts) {
+            case 'f':
+                printf("turned on fps counter\n");
+                enable_fps = true;
+                break;
+            case 's':
+                debug_nodie = true;
+                break;
+            case 'g':
+                debug_shotgun = true;
+                break;
+            case 'b':
+                debug_bomb = true;
+                break;
+            case '?':
+            default:
+                break;
+        }
+
+    }
+
     InitAudioDevice();
     if(IsAudioDeviceReady()) {
         sfx_shoot = LoadSound(SFX_SHOOT_FILE);
@@ -246,7 +271,7 @@ int main(void) {
             spin_ship(0);
             StopSound(sfx_music);
         }
-        if(IsKeyPressed('A') && (active_powerups & BOMB)) {
+        if(IsKeyPressed('A') && ((active_powerups & BOMB) || debug_bomb)) {
             active_powerups ^= BOMB;
             launch_bomb();
         }
@@ -281,6 +306,8 @@ int main(void) {
             }
             if(active_powerups & BOMB && bomb_proj.w == -1) 
                 DrawCircleSectorLines(flatten(translate(nose, center)), 4.0f, 0, 360, 360, RED);
+            if(debug_shotgun)
+                enable_shotgun();
         } else if(!(active_powerups & GOD)) {
             DrawText("YOU DIED", (scrW/2)-(MeasureText("YOU DIED", 64)/2), (scrH/2)-64, 64, RED);
             DrawText("FUCK YOU", (scrW/2)-(MeasureText("FUCK YOU", 16)/2), (scrH/2)-8, 16, RED);
@@ -302,7 +329,8 @@ int main(void) {
             draw_shield_pickup();
         DrawText("[H]elp", (scrW-MeasureText("[H]elp", 32)-32), scrH-34, 32, WHITE); 
         DrawText(TextFormat("%d", score), 4, scrH-34, 32, WHITE);
-        DrawFPS(0, 0);
+        if(enable_fps)
+            DrawFPS(0, 0);
         EndDrawing();
         if(throttle && !IsSoundPlaying(sfx_music)) {
             PlaySound(sfx_music);
@@ -450,7 +478,6 @@ void update_bomb() {
         bomb_proj.w = -1;
     }
     if (!onscreen(flatten(bomb_proj))) {
-        printf("bomb off\n");
         bomb_proj.w = -1;
     }
 }