aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavid <[email protected]>2026-07-16 03:03:56 -0300
committerdavid <[email protected]>2026-07-16 03:03:56 -0300
commit9c0c7b942e2fc85eb5137ff570605ff608fd0ec4 (patch)
tree65c71b3dfc93e41e7c21995139ca2eee027dc5d1
parent290ea5659f2555d920a6077f078e1c60746b049a (diff)
downloadpetratc-9c0c7b942e2fc85eb5137ff570605ff608fd0ec4.tar.gz
petratc-9c0c7b942e2fc85eb5137ff570605ff608fd0ec4.zip
started a new game finally... also i fixed the compiler complaints and idk what else i did... if you're interested you can look at the diff
-rw-r--r--defs.h1
-rw-r--r--games/gameclicker.c61
-rw-r--r--games/gamemaze.c20
-rw-r--r--petratc.c17
4 files changed, 92 insertions, 7 deletions
diff --git a/defs.h b/defs.h
index 0831813..00f680c 100644
--- a/defs.h
+++ b/defs.h
@@ -4,5 +4,6 @@
void gameguess(void);
void gamecatch(void);
void gamemaze(void);
+void gameclicker(void);
#endif
diff --git a/games/gameclicker.c b/games/gameclicker.c
new file mode 100644
index 0000000..7e723de
--- /dev/null
+++ b/games/gameclicker.c
@@ -0,0 +1,61 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <ncurses.h>
+#include "../rat.h"
+
+#define width getmaxx(stdscr)
+#define height getmaxy(stdscr)
+
+int running;
+int row = 1;
+
+static void stop() {
+ clear();
+ refresh();
+ endwin();
+ running = 0;
+}
+
+void gameclicker(){
+
+ srand(time(NULL));
+ static int initialized = 0;
+ if(!initialized){ initscr();}else{refresh();}
+ ++initialized;
+
+ noecho();
+ cbreak();
+ nodelay(stdscr, TRUE);
+ keypad(stdscr, TRUE);
+ curs_set(0);
+
+ int winh = height * 0.96;
+ int winw = width * 0.96;
+ int boxy = (height - winh) / 2;
+ int boxx = (width - winw) / 2;
+ WINDOW *win = newwin(winh, winw, boxy, boxx);
+
+ box(win, 0, 0); //box?
+
+ //should i wrap all this into a macro in rat.h to not have to write all of this every time i make a new game?
+
+ running = 1;
+
+ mvwprintw(win, row ++, 2, "hi");
+ while(running){
+ if(!running){stop();}
+ int ch = getch();
+ switch (ch) {
+ case 'q': case 'Q': stop(); break;
+ }
+
+
+ wrefresh(win);
+ usleep(16667); //60 fps according to google ai overview lmao
+ }
+
+stop();
+printf("yeah");
+}
diff --git a/games/gamemaze.c b/games/gamemaze.c
index 8b35afc..5dbce8f 100644
--- a/games/gamemaze.c
+++ b/games/gamemaze.c
@@ -248,13 +248,25 @@ void gamemaze(){
case 'q': case 'Q': stop(); break;
case 'r': case 'R': properrestart(&curs, &W, &H); break;
case 'a': case 'A': case KEY_LEFT:
- if (!iswall(curs.posy, curs.posx - 1)) curs.posx -= 1; break;
+ if(!iswall(curs.posy, curs.posx - 1)){
+ curs.posx -= 1;
+ }
+ break;
case 'd': case 'D': case KEY_RIGHT:
- if (!iswall(curs.posy, curs.posx + 1))curs.posx += 1; break;
+ if (!iswall(curs.posy, curs.posx + 1)){
+ curs.posx += 1;
+ }
+ break;
case 'w': case 'W': case KEY_UP:
- if (!iswall(curs.posy - 1, curs.posx))curs.posy -= 1; break;
+ if (!iswall(curs.posy - 1, curs.posx)){
+ curs.posy -= 1;
+ }
+ break;
case 's': case 'S': case KEY_DOWN:
- if (!iswall(curs.posy + 1, curs.posx))curs.posy += 1; break;
+ if (!iswall(curs.posy + 1, curs.posx)){
+ curs.posy += 1;
+ }
+ break;
}
eatcheese(&curs);
diff --git a/petratc.c b/petratc.c
index e21bf43..e315587 100644
--- a/petratc.c
+++ b/petratc.c
@@ -69,8 +69,12 @@ void load(void) {
rat.age = time(NULL);
return;
}
- fscanf(f, "%f\n%f\n%f\n%f\n%f\n%d\n",
- &rat.hunger, &rat.love, &rat.fun, &rat.clean, &rat.health, &rat.age);
+ if(fscanf(f, "%f\n%f\n%f\n%f\n%f\n%d\n",
+ &rat.hunger, &rat.love, &rat.fun, &rat.clean, &rat.health, &rat.age) != 6){
+ fprintf(stderr, "error: failed to initialize save data.\n");
+ }
+ //this should shut the compiler up
+
fclose(f);
}
@@ -91,6 +95,7 @@ void setstat(){
rat.age = timenow; //thinking about this makes my cortisol spike so i'll just ignore it even more
+ //nah nvm this will only give us problems in 2038
}
@@ -126,6 +131,7 @@ void printrat(WINDOW *win){
mvwprintw(win, row++, 2, "1: play a game! (fun up)");
mvwprintw(win, row++, 2, "2: go to the maze (hunger up)");
mvwprintw(win, row++, 2, "4: take a shower! (clean up)");
+ mvwprintw(win, row++, 2, "5: clicker the cheese! (all up)");
mvwprintw(win, row++, 2, "9: print me! (refreshes stats)");
mvwprintw(win, row++, 2, "0: exit...");
@@ -146,7 +152,7 @@ int truing = 1;
keypad(stdscr, TRUE);
curs_set(0);
- WINDOW *win = newwin(20, 40, 1, 1);
+ WINDOW *win = newwin(25, 45, 1, 1);
printrat(win);
while(truing){
@@ -171,6 +177,11 @@ int truing = 1;
printf("your rat feels cleaner!\n\n");
refresh();
break;
+ case '5':
+ endwin();
+ gameclicker();
+ refresh();
+ break;
case '9': break;
case '0': truing = 0; break;
}