diff --git a/Makefile b/Makefile index a9b1c60..91b54d5 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ CC = gcc CFLAGS = -Wall -Wextra TARGET = petratc -SRC = petratc.c +SRC = petratc.c $(wildcard games/*.c) PREFIX = /usr/local $(TARGET): $(SRC) diff --git a/cpetrat b/cpetrat deleted file mode 100755 index 4a64b8e..0000000 Binary files a/cpetrat and /dev/null differ diff --git a/defs.h b/defs.h new file mode 100644 index 0000000..4125168 --- /dev/null +++ b/defs.h @@ -0,0 +1,7 @@ +#ifndef defs_h +#define defs_h + +void gameguess(void); +void gamecatch(void); + +#endif diff --git a/games/gamecatch.c b/games/gamecatch.c new file mode 100644 index 0000000..eb8c6c9 --- /dev/null +++ b/games/gamecatch.c @@ -0,0 +1,8 @@ +#include +#include +#include "../rat.h" +void gamecatch(){ + + printf("67"); + +} diff --git a/games/gameguess.c b/games/gameguess.c new file mode 100644 index 0000000..ad6c9be --- /dev/null +++ b/games/gameguess.c @@ -0,0 +1,28 @@ +#include +#include +#include "../rat.h" + +void gameguess(){ +int guess; +int solved = 0; +int range = 100; + +int correct = (rand() % (range + 1)); + +printf("let's play a game, squeak!~ you gues a number between 0 and %d!\n", range); + + +while(solved != 1){ + +scanf("%d", &guess); + +if(guess < correct){ +printf("number too low try again\n"); +}else if(guess > correct){ +printf("number too high try again\n"); +}else {printf("yes!! correct! squeaaakk!~\n"); solved = 1;} +} + + addstat(&rat.fun); + +} diff --git a/petratc.c b/petratc.c index 0d6308e..5334e7b 100644 --- a/petratc.c +++ b/petratc.c @@ -3,6 +3,7 @@ #include #include #include "rat.h" +#include "defs.h" #ifdef __APPLE__ #define ratpath "%s/Library/Application Support/rat" @@ -12,6 +13,28 @@ #define ratsave "%s/.local/share/rat/rat.txt" #endif + char ratart[] = + " .---.\n (\\./) \\.......-\n >' '< (__.'\"\"\"\"\"\"\n \" ` \" \"_"; + + char *messages[] = { + "squeak!", + "squeak! !", + "squeak", + "squeak...", + "SQUEAK", + "SQUEAK!!", + "SQUEAAAKKKKK", + }; + +void addstat(float *guy){ + + if(*guy < 98.5){ + *guy += 1.5; + } else{*guy += 0.05;} +} + +Rat rat; + void save(void) { char path[256]; snprintf(path, sizeof(path), ratpath, getenv("HOME")); @@ -63,13 +86,6 @@ void setstat(){ rat.age = timenow; //thinking about this makes my cortisol spike so i'll just ignore it even more } -//stupid function but it's smart if you think about it. just ignore it -void addstat(float *guy){ - - if(*guy < 98.5){ - *guy += 1.5; - } else{*guy += 0.05;} -} void printrat(){ @@ -81,41 +97,6 @@ void printrat(){ } -void gameguess(){ - int guess; - int solved = 0; - int range = 100; - - int correct = (rand() % (range + 1)); - - printf("let's play a game, squeak!~ you gues a number between 0 and %d!\n", range); - - - while(solved != 1){ - - scanf("%d", &guess); - - if(guess < correct){ - printf("number too low try again\n"); - }else if(guess > correct){ - printf("number too high try again\n"); - }else {printf("yes!! correct! squeaaakk!~\n"); solved = 1;} - } - - addstat(&rat.fun); - -} - -void showergame(){ - -//ignore this i'm working on it - - - - addstat(&rat.clean); -} - - int main(){ srand(time(NULL)); @@ -132,7 +113,7 @@ int truing = 1; switch(choice){ case 1: gameguess(); break; - case 4: showergame(); break; + case 4: gamecatch(); break; case 8: printf("%d\n", rat.age); break; case 9: printrat(); break; case 0: truing = 0; break; diff --git a/rat.h b/rat.h index a3fe10f..b826e74 100644 --- a/rat.h +++ b/rat.h @@ -1,22 +1,18 @@ - char ratart[] = - " .---.\n (\\./) \\.......-\n >' '< (__.'\"\"\"\"\"\"\n \" ` \" \"_"; +#ifndef rat_h +#define rat_h - char *messages[] = { - "squeak!", - "squeak! !", - "squeak", - "squeak...", - "SQUEAK", - "SQUEAK!!", - "SQUEAAAKKKKK", - }; +typedef struct { + float hunger; + float love; + float fun; + float clean; + float health; + int age; +} Rat; - struct{ - float hunger; - float love; - float fun; - float clean; - float health; - int age; +extern char ratart[]; +extern char *messages[]; +extern Rat rat; +void addstat(float *guy); - }rat; +#endif