Compare commits

...
3 Commits
Author SHA1 Message Date
david f161c1e4a9 fixed stupid things happening if you're stupid 2026-05-04 06:25:40 -03:00
david 112351f9bc fixed exiting shower game 2026-05-04 04:20:31 -03:00
david 6a91e36534 finished gamecatch now you can take a shower 2026-05-04 03:47:21 -03:00
3 changed files with 81 additions and 20 deletions

No files matched your search

+70 -15
View File
@@ -34,35 +34,49 @@
// i just realized this is basically cmatrix with a little guy at the bottom
*/
#define width 40;
#define height 50;
#define width 40
#define height getmaxy(stdscr)
#define maxdrops 70
int running;
int won;
int howmany;
typedef struct{
int posx;
int posy;
char *symbol[3];
int active;
char *symbol;
}drop;
typedef struct{
int posx;
char *face[2];
int direction;
}cursor;
void spawndrops(){
return;
static drop droop[maxdrops];
void spawndrops() {
for (int i = 0; i < maxdrops; i++) {
if (!droop[i].active) {
droop[i].posx = 1 + rand() % (width - 2);
droop[i].posy = 0;
droop[i].active = 1;
char *symbols[] = {"O", "0", "o"};
droop[i].symbol = symbols[rand() % 3];
break;
}
}
}
void stop() {
if (!isendwin()) {
endwin();
}
addstat(&rat.clean);
clear();
refresh();
endwin();
if(won){addstat(&rat.clean);}
won = 0;
running = 0;
}
@@ -75,28 +89,69 @@ void gamecatch(){
static int initialized = 0;
if(initialized == 0){ initscr();}else{refresh();} // turns out you don't wanna call initscr() many times per session so do this because it glitches otherwise
++initialized;
howmany = 0;
noecho();
cbreak();
nodelay(stdscr, TRUE);
keypad(stdscr, TRUE);
curs_set(0);
drop droop = {0, 0, {"O", "0", "o"}}; //on spawn random which symbol it'll use
cursor curs = {20, {"(>.<)_", "_(>.<)" }}; //face[0] is going left face[1] is going right
cursor curs = {width / 2, {"(>.<)_", "_(>.<)"}, 0};
for (int i = 0; i < maxdrops; i++) droop[i].active = 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--;
curs.posx-= 2;
if(curs.posx < 0) curs.posx = width - 6;
curs.direction = 0;
break;
case 'd': case 'D': case KEY_RIGHT:
curs.posx++;
curs.posx += 2;
if(curs.posx > width - 6) curs.posx = 0;
curs.direction = 1 ;
break;
}
if (!running) break;
if (rand() % 10 < 3) spawndrops();
clear();
mvprintw(0, width + 2, "caught: %d/30", howmany);
mvprintw(1, width + 2, "(catch 30 to win!)");
mvprintw(2, width + 2, "move with A and D");
mvprintw(3, width + 2, "or the or the corresponding arrows");
for (int i = 0; i < maxdrops; i++) {
if (droop[i].active) {
mvaddstr(droop[i].posy, droop[i].posx, droop[i].symbol);
droop[i].posy++;
if (droop[i].posy >= height) droop[i].active = 0;
if (droop[i].posy == height - 1 &&
droop[i].posx >= curs.posx &&
droop[i].posx <= curs.posx + 5) {
droop[i].active = 0;
howmany++;
if(howmany == 30){won = 1; running = 0; stop();}
}
}
}
mvaddstr(height - 1, curs.posx, curs.face[curs.direction]);
refresh();
usleep(100000);
}
stop();
+4 -1
View File
@@ -14,7 +14,10 @@ printf("let's play a game, squeak!~ you gues a number between 0 and %d!\n", rang
while(solved != 1){
scanf("%d", &guess);
if(scanf("%d", &guess) != 1){
while(getchar() != '\n'); //flush the bad input here too
continue;
}
if(guess < correct){
printf("number too low try again\n");
+7 -4
View File
@@ -92,7 +92,7 @@ void printrat(){
printf("%s\n", ratart);
int howmany = sizeof(messages) / sizeof(messages[0]);
printf("%s\n", messages[rand() % howmany]);
printf("rat hunger: %.2f, rat love: %.2f, rat fun: %.2f, rat dirt: %.2f, rat health: %.2f\n",
printf("rat hunger: %.2f, rat love: %.2f, rat fun: %.2f, rat clean: %.2f, rat health: %.2f\n",
rat.hunger, rat.love, rat.fun, rat.clean, rat.health);
}
@@ -108,13 +108,16 @@ int truing = 1;
printrat();
while(truing){
printf("1: play a game! (fun up), 4: take a shower!, 9: print me!, 0: exit...\n");
scanf("%d", &choice);
printf("1: play a game! (fun 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
continue;
}
switch(choice){
case 1: gameguess(); break;
case 4: gamecatch(); break;
case 8: printf("%d\n", rat.age); break;
case 9: printrat(); break;
case 0: truing = 0; break;
}