mode = 2;
sprintf (msg, "End of game");
msgwindow (msg, xboard + (board->width - strlen (msg)) / 2, yboard + (board->height - 1) / 2, strlen (msg), 1);
+ waitforkey ('q');
+ break;
}
int ch = getch ();
case KEY_ESC:
case 'h':
helpwindow (help, xboard + (board->width - strmaxlen (help, '\n')) / 2, yboard + (board->height - strnbchr (help, '\n') - 1) / 2);
- while (getch () == ERR) {
- msleep (200);
- }
+ waitforkey (0);
tic (&turn);
draw = 1;
break;
case 'p':
sprintf (msg, "Game paused");
msgwindow (msg, xboard + (board->width - strlen (msg)) / 2, yboard + (board->height - 1) / 2, strlen (msg), 1);
- while (getch () == ERR) {
- msleep (200);
- }
+ waitforkey (0);
tic (&turn);
draw = 1;
break;
break;
}
- if (mode == 2) {
- continue;
- }
-
/* game controls */
switch (ch) {
case KEY_UP:
+#include <curses.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
usleep (msec * 1000);
}
+void waitforkey (char key)
+{
+ char c;
+ while ((c = getch ()) == ERR) {
+ if ((key) && (c == key)) {
+ break;
+ }
+ msleep (200);
+ }
+}
+
/* vim: set ts=4 sw=4 et: */