From 3559eb4af615fe7a1cba96f3ef2c94d3eaf8b80f Mon Sep 17 00:00:00 2001 From: Colleague Riley Date: Wed, 17 Aug 2022 22:39:23 -0400 Subject: [PATCH] updated build system --- Makefile | 18 ++++++++++++++++++ RMakefile | 2 +- RSGL-Dino-Game | 1 + source/main.cpp | 9 ++++++--- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 Makefile create mode 100755 RSGL-Dino-Game diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..9bfd284 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +OUTPUT = RSGL-Dino-Game +GXX = g++ +SOURCE = source/*.cpp +LIBS = $(shell RSGL-static) + +build: + mkdir -p build + $(GXX) $(SOURCE) $(LIBS) -o build/$(OUTPUT) + mkdir -p ~/.cache/$(OUTPUT) + echo "1" > ~/.cache/$(OUTPUT)/highScore + cp -r res ./build + + +install: + chmod +x $(OUTPUT) + cp $(OUTPUT) /usr/bin + mkdir -p /usr/share/$(OUTPUT) + cp -r build/* /usr/share/$(OUTPUT) \ No newline at end of file diff --git a/RMakefile b/RMakefile index 3937878..b3aa1fc 100644 --- a/RMakefile +++ b/RMakefile @@ -1,5 +1,5 @@ SOURCE += source/*.cpp -LIBS += -lRSGL +LIBS += $(RSGL-static) ARGS += -g OUTPUT = RSGL-Dino-Game GXX = g++ diff --git a/RSGL-Dino-Game b/RSGL-Dino-Game new file mode 100755 index 0000000..1abb194 --- /dev/null +++ b/RSGL-Dino-Game @@ -0,0 +1 @@ +cd /usr/share/RSGL-Dino-Game && ./RSGL-Dino-Game ~/.cache/RSGL-Dino-Game/ \ No newline at end of file diff --git a/source/main.cpp b/source/main.cpp index f9a7dd5..cf28398 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -35,7 +35,10 @@ bool AI(){ return memory.at(distObj).y > memory.at(distObj).x; } -int main(){ +int main(int argc, char** argv){ + std::string hsDir=""; + if (argc > 1) hsDir = std::string(argv[1]); + srand(time(NULL)); std::vector dots; std::vector clouds; @@ -47,7 +50,7 @@ int main(){ for (int x=(!y); x < 3; x++) Cactuses.insert(Cactuses.end(), { win.r.width+80, (20*(y-1))+(win.r.width/2-20), 20*(y+1), 45 }); } Cactuses.insert(Cactuses.end(),{win.r.width+80,(win.r.width/2+20),20,25}); - if (readFile("highScore") != "") highScore=std::stoi(readFile("highScore")); + if (readFile(hsDir+"highScore") != "") highScore=std::stoi(readFile(hsDir+"highScore")); std::string dinoImg="res/images/lonicidle.png"; while(running){ @@ -89,7 +92,7 @@ int main(){ } if (init){ if (scoreTick >= speed*2){ scoreTick=0; score++; } if (highScore < score){ - FILE* f = fopen("highScore","w+"); + FILE* f = fopen(std::string(hsDir+"highScore").c_str(),"w+"); fwrite(std::to_string(score).c_str(),std::to_string(score).size(),1,f); fclose(f); highScore=score; }