mirror of
https://git.squeakyrat.moe/petratc/
synced 2026-11-04 18:35:43 +01:00
segfault if you go to negative numbers in the maze game...
This commit is contained in:
1 parent
20da733459
commit
8d63c9dd1c
3 files changed
+13
-13
No files matched your search
+3
-3
@@ -276,8 +276,8 @@ 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;
|
||||
if(curs.posx > 0 && !iswall(curs.posy, curs.posx - 1)){
|
||||
curs.posx -= 1;
|
||||
}
|
||||
break;
|
||||
case 'd': case 'D': case KEY_RIGHT:
|
||||
@@ -286,7 +286,7 @@ void gamemaze(){
|
||||
}
|
||||
break;
|
||||
case 'w': case 'W': case KEY_UP:
|
||||
if (!iswall(curs.posy - 1, curs.posx)){
|
||||
if (curs.posy > 0 && !iswall(curs.posy - 1, curs.posx)){
|
||||
curs.posy -= 1;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -33,9 +33,9 @@ char *funfact[] = {
|
||||
|
||||
|
||||
Rat rat;
|
||||
//i was cleaning the code up a bit and what the fuck is this
|
||||
/*i was cleaning the code up a bit and what the fuck is this
|
||||
//it's so funny Rat rat
|
||||
|
||||
*/
|
||||
void printrat(WINDOW *win){
|
||||
|
||||
werase(win);
|
||||
@@ -101,13 +101,13 @@ int truing = 1;
|
||||
case '2':
|
||||
endwin();
|
||||
gamemaze();
|
||||
//printf("the maze is really dark squeak...\n\n");
|
||||
/*printf("the maze is really dark squeak...\n\n");*/
|
||||
refresh();
|
||||
break;
|
||||
case '4':
|
||||
endwin();
|
||||
gamecatch();
|
||||
//printf("your rat feels cleaner!\n\n");
|
||||
/*printf("your rat feels cleaner!\n\n");*/
|
||||
refresh();
|
||||
break;
|
||||
case '5':
|
||||
@@ -118,7 +118,7 @@ int truing = 1;
|
||||
case '9': break;
|
||||
case '0': truing = 0; break;
|
||||
}
|
||||
// i will put those printfs where the squeaks go but i have no clue how to do that today
|
||||
/* i will put those printfs where the squeaks go but i have no clue how to do that today */
|
||||
if(truing) printrat(win);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ void load(void) {
|
||||
&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
|
||||
/*this should shut the compiler up*/
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
@@ -67,12 +67,12 @@ float decay(float current, float dayspassed, float rate) {
|
||||
void setstat(){
|
||||
int timenow = time(NULL);
|
||||
int newage = timenow - rat.age;
|
||||
float days = newage / 86400.0f; //one day
|
||||
float days = newage / 86400.0f; /*one day*/
|
||||
|
||||
rat.hunger = decay(rat.hunger, days, 50.0f); //hungry beast
|
||||
rat.love = decay(rat.love, days, 1.1f); //rats love you they won't hate you easly
|
||||
rat.hunger = decay(rat.hunger, days, 50.0f); /*hungry beast*/
|
||||
rat.love = decay(rat.love, days, 1.1f); /*rats love you they won't hate you easly*/
|
||||
rat.fun = decay(rat.fun, days, 25.0f);
|
||||
rat.clean = decay(rat.clean, days, 5.0f);//rats are surprisingly clean they clean themselves so slow
|
||||
rat.clean = decay(rat.clean, days, 5.0f);/*rats are surprisingly clean they clean themselves so slow*/
|
||||
rat.health = decay(rat.health, days, 0.6f);
|
||||
|
||||
rat.age = timenow;
|
||||
|
||||
Reference in new issue
Block a user