From: AynRandDuran Date: Sat, 17 Jul 2021 23:26:03 +0000 (-0400) Subject: Statically link so it's shareable X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=3597324758894a2f71f22c4cc74854fdf3787dcc;p=assteroids Statically link so it's shareable --- diff --git a/Makefile b/Makefile index 1c7eab2..47bb147 100644 --- 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 $@ diff --git a/assteroids.h b/assteroids.h index 34d30fd..95341cd 100644 --- a/assteroids.h +++ b/assteroids.h @@ -1,10 +1,8 @@ #ifndef __ass #define __ass - #include #include #include - #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 diff --git a/game.cpp b/game.cpp index 254d47e..10e7509 100644 --- a/game.cpp +++ b/game.cpp @@ -1,5 +1,6 @@ #include #include +#include #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; } }