ref: c62bc97a60f7069d1354edd37a61b6722ecc035a
parent: 3fe6dc0d8361f98d145d82af346814ddb7563e77
author: glenda <glenda@9front.local>
date: Thu Aug 5 00:07:41 EDT 2021
corrected some formatting
--- a/schnek.c
+++ b/schnek.c
@@ -28,7 +28,8 @@
int eaten=0;
int length=0;
-void newfood(void) {
+void
+newfood(void) {
Point newfood;
Rectangle r = screen->r;
@@ -38,7 +39,8 @@
food = newfood;
}
-void resize(int x, int y) {
+void
+resize(int x, int y) {
int fd;
fd = open("/dev/wctl", OWRITE);
@@ -48,7 +50,8 @@
}
}
-void redraw(Image *screen) {
+void
+redraw(Image *screen) {
static Rectangle r;
Point pt;
Rectangle foo;
@@ -70,7 +73,8 @@
flushimage(display, 1);
}
-void endgame(void) {
+void
+endgame(void) {
print("Moves: %d\n", moves);
print("Eaten: %d\n", eaten);
print("Length: %d\n", length);
@@ -78,7 +82,8 @@
exits(0);
}
-void moveschnek(void) {
+void
+moveschnek(void) {
Rectangle r = screen->r;
Point head, pt;
int i;
@@ -147,13 +152,15 @@
redraw(screen);
}
-void eresized(int new) {
+void
+eresized(int new) {
if(new && getwindow(display, Refnone) < 0)
fprint(2,"can't reattach to window");
redraw(screen);
}
-void pause(int) {
+void
+pause(void) {
Event e;
int key, inputk;
for(;;) {
@@ -171,7 +178,8 @@
}
}
-void main(int, char**) {
+void
+main(int, char**) {
Event e;
Mouse m;
Menu menu;
@@ -214,40 +222,40 @@
}
}
} else if (key == Ekeyboard) {
- inputk = e.kbdc;
- switch (inputk) {
- case 'h':
- if (s.d != RIGHT)
- s.d = LEFT;
- break;
- case 'j':
- if (s.d != UP)
- s.d = DOWN;
- break;
- case 'k':
- if (s.d != DOWN)
- s.d = UP;
- break;
- case 'l':
- if (s.d != LEFT)
- s.d = RIGHT;
- break;
- case 'q':
- endgame();
- break;
- case 'p':
- pause(1);
- break;
- default:
- break;
- }
+ inputk = e.kbdc;
+ switch (inputk) {
+ case 'h':
+ if (s.d != RIGHT)
+ s.d = LEFT;
+ break;
+ case 'j':
+ if (s.d != UP)
+ s.d = DOWN;
+ break;
+ case 'k':
+ if (s.d != DOWN)
+ s.d = UP;
+ break;
+ case 'l':
+ if (s.d != LEFT)
+ s.d = RIGHT;
+ break;
+ case 'q':
+ endgame();
+ break;
+ case 'p':
+ pause();
+ break;
+ default:
+ break;
+ }
} else if (key == timer) {
moveschnek();
if (counter == 8) {
newfood();
counter=0;
- } else {
- counter++;
+ } else {
+ counter++;
}
if (starving == 36) {
s.length--;
@@ -256,9 +264,9 @@
starving++;
}
if (s.length == 0) {
- print("You've starved!\n");
- endgame();
- }
+ print("You've starved!\n");
+ endgame();
+ }
}
}
}