ref: 98b9d272f49d11cdc1e74d6e89badab1b8534d03
parent: 456b15a9e87b23c32252ebf336b26e49ba7ecb3a
author: glenda <glenda@9front.local>
date: Mon Aug 2 19:45:32 EDT 2021
tidying a bit
--- a/schnek.c
+++ b/schnek.c
@@ -32,7 +32,7 @@
Point newfood;
Rectangle r = screen->r;
- newfood.x = r.min.x + ntruerand(14)*10;
+ newfood.x = r.min.x + (14)*10;
newfood.y = r.min.y + ntruerand(14)*10;
food = newfood;
@@ -87,7 +87,7 @@
if (s.length < 50) {
if (s.p[s.head].x == food.x && s.p[s.head].y == food.y) {
s.length++;
- /* newfood(); */
+
if(s.length > length){
length=s.length;
}
@@ -153,26 +153,22 @@
redraw(screen);
}
-void pause(void) {
+void pause(int) {
Event e;
int key, inputk;
for(;;) {
key = event(&e);
inputk = e.kbdc;
- /* print("here\n"); */
if (key == Ekeyboard) {
switch (inputk) {
case 'p':
- /* print("here\n"); */
- /* break; */
return;
case 'q':
endgame();
break;
- }
+ }
}
}
- /* return; */
}
void main(int, char**) {
@@ -240,27 +236,26 @@
endgame();
break;
case 'p':
- pause();
+ pause(1);
break;
default:
break;
}
- } else if(key == timer) {
- moveschnek();
- if (counter == 8) {
- newfood();
- counter=0;
+ } else if (key == timer) {
+ moveschnek();
+ if (counter == 8) {
+ newfood();
+ counter=0;
} else {
counter++;
- }
- if (starving == 36) {
- s.length--;
- starving=0;
- } else {
- starving++;
-
- }
- if (s.length == 0) {
+ }
+ if (starving == 36) {
+ s.length--;
+ starving=0;
+ } else {
+ starving++;
+ }
+ if (s.length == 0) {
print("You've starved!\n");
endgame();
}