aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavid <[email protected]>2026-05-04 06:25:40 -0300
committerdavid <[email protected]>2026-05-04 06:25:40 -0300
commitf161c1e4a9cb7393b7fd155a6bcab28b2ca94565 (patch)
tree0250ca4178ac9b26ccd279aeae9ebff0241b4277
parent112351f9bc0d6a80f9e25b1c69de80b573b3d7c4 (diff)
downloadpetratc-f161c1e4a9cb7393b7fd155a6bcab28b2ca94565.tar.gz
petratc-f161c1e4a9cb7393b7fd155a6bcab28b2ca94565.zip
fixed stupid things happening if you're stupid
-rw-r--r--games/gamecatch.c10
-rw-r--r--games/gameguess.c5
-rw-r--r--petratc.c7
3 files changed, 13 insertions, 9 deletions
diff --git a/games/gamecatch.c b/games/gamecatch.c
index 69310c8..dadf770 100644
--- a/games/gamecatch.c
+++ b/games/gamecatch.c
@@ -72,11 +72,9 @@ void spawndrops() {
}
void stop() {
- if (!isendwin()) {
- clear();
- refresh();
- endwin();
- }
+ clear();
+ refresh();
+ endwin();
if(won){addstat(&rat.clean);}
won = 0;
running = 0;
@@ -145,7 +143,7 @@ void gamecatch(){
droop[i].posx <= curs.posx + 5) {
droop[i].active = 0;
howmany++;
- if(howmany == 30){won = 1; running = 0;}
+ if(howmany == 30){won = 1; running = 0; stop();}
}
}
}
diff --git a/games/gameguess.c b/games/gameguess.c
index ad6c9be..940e4c5 100644
--- a/games/gameguess.c
+++ b/games/gameguess.c
@@ -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");
diff --git a/petratc.c b/petratc.c
index 5889f89..0a60b46 100644
--- a/petratc.c
+++ b/petratc.c
@@ -109,12 +109,15 @@ int truing = 1;
while(truing){
printf("1: play a game! (fun up), 4: take a shower! (clean up), 9: print me!, 0: exit...\n");
- scanf("%d", &choice);
+
+ 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;
}