Skip to content
This repository has been archived by the owner on Jul 29, 2023. It is now read-only.

Commit

Permalink
updated build system
Browse files Browse the repository at this point in the history
  • Loading branch information
ColleagueRiley committed Aug 18, 2022
1 parent 4602a72 commit 3559eb4
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion RMakefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SOURCE += source/*.cpp
LIBS += -lRSGL
LIBS += $(RSGL-static)
ARGS += -g
OUTPUT = RSGL-Dino-Game
GXX = g++
Expand Down
1 change: 1 addition & 0 deletions RSGL-Dino-Game
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cd /usr/share/RSGL-Dino-Game && ./RSGL-Dino-Game ~/.cache/RSGL-Dino-Game/
9 changes: 6 additions & 3 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<RSGL::rect> dots;
std::vector<RSGL::rect> clouds;
Expand All @@ -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){
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 3559eb4

Please sign in to comment.