aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--defs.h1
-rw-r--r--games/gamecatch.c8
-rw-r--r--games/gamemaze.c93
-rw-r--r--petratc.c3
4 files changed, 100 insertions, 5 deletions
diff --git a/defs.h b/defs.h
index 4125168..0831813 100644
--- a/defs.h
+++ b/defs.h
@@ -3,5 +3,6 @@
void gameguess(void);
void gamecatch(void);
+void gamemaze(void);
#endif
diff --git a/games/gamecatch.c b/games/gamecatch.c
index 836dca4..239c42e 100644
--- a/games/gamecatch.c
+++ b/games/gamecatch.c
@@ -38,9 +38,9 @@
#define height getmaxy(stdscr)
#define maxdrops 70
-int running;
-int won;
-int howmany;
+static int running;
+static int won;
+static int howmany;
typedef struct{
@@ -71,7 +71,7 @@ void spawndrops() {
}
}
-void stop() {
+static void stop() {
clear();
refresh();
endwin();
diff --git a/games/gamemaze.c b/games/gamemaze.c
new file mode 100644
index 0000000..c47d2d5
--- /dev/null
+++ b/games/gamemaze.c
@@ -0,0 +1,93 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <unistd.h>
+#include <ncurses.h>
+#include "../rat.h"
+
+/*
+// i'm probably gonna use a loop erased random walk algorithm
+//the screen will start as 100% walls then slowly build a path
+//(i have no idea how many resources this will take, if it's slow i'll ask grok to multithread it)
+//
+// a couple ammount of cheeses will spawn in places where there are no walls
+// eating cheeses will add to the base addstat() but addstat() only will be called if 1 cheese is eaten
+// idk what else to do here.
+// you start at the top and end at the bottom if i ever wanna automate taking care of the rat
+*/
+
+#define width getmaxx(stdscr)
+#define height getmaxy(stdscr)
+
+static int running;
+static int won;
+static int found;
+
+typedef struct{
+
+ int posy;
+ int posx;
+ char *face[1];
+
+}cursor;
+
+static void stop() {
+ clear();
+ refresh();
+ endwin();
+ if(won){addstat(&rat.hunger); addstat(&rat.fun); printf("the rat feels less hungry...\n\n");}
+ won = 0;
+ found = 0;
+ running = 0;
+}
+//yes i stole the code from gamecatch shut up it works
+
+
+
+
+
+void gamemaze(){
+
+ srand(time(NULL));
+ static int initialized = 0;
+ if(initialized == 0){ initscr();}else{refresh();}
+ ++initialized;
+
+ found = 0;
+
+ noecho();
+ cbreak();
+ nodelay(stdscr, TRUE);
+ keypad(stdscr, TRUE);
+ curs_set(0);
+
+ cursor curs = {0, 0, {"@"}};
+
+ running = 1;
+
+ while (running) {
+ if (!running) stop();
+ int ch = getch();
+ switch (ch) {
+ case 'q': case 'Q': stop(); break;
+ case 'a': case 'A': case KEY_LEFT:
+ curs.posx -= 1; break;
+ case 'd': case 'D': case KEY_RIGHT:
+ curs.posx += 1; break;
+ case 'w': case 'W': case KEY_UP:
+ curs.posy -= 1; break;
+ case 's': case 'S': case KEY_DOWN:
+ curs.posy += 1; break;
+ }
+
+ if (!running) break;
+ clear();
+
+ mvaddstr(curs.posy, curs.posx, curs.face[0]);
+
+ refresh();
+ usleep(50000);
+ }
+
+stop();
+}
diff --git a/petratc.c b/petratc.c
index 0a60b46..b12a4f4 100644
--- a/petratc.c
+++ b/petratc.c
@@ -108,7 +108,7 @@ int truing = 1;
printrat();
while(truing){
- printf("1: play a game! (fun up), 4: take a shower! (clean up), 9: print me!, 0: exit...\n");
+ printf("1: play a game! (fun up), 2: go down to the maze... (hunger up), 4: take a shower! (clean up), 9: print me!, 0: exit...\n");
if(scanf("%d", &choice) != 1){
while(getchar() != '\n'); //flush the bad input if you're a bad boy and put q instead of 1
@@ -117,6 +117,7 @@ int truing = 1;
switch(choice){
case 1: gameguess(); break;
+ case 2: gamemaze(); break;
case 4: gamecatch(); break;
case 9: printrat(); break;
case 0: truing = 0; break;