From 6d501bfc7c88d2901fb2322ab8552ffb1b06510f Mon Sep 17 00:00:00 2001 From: Serge Vakulenko Date: Mon, 30 Nov 2015 12:47:45 -0800 Subject: [PATCH] Update flappy game. --- share/examples/gpanel/flappy.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/share/examples/gpanel/flappy.c b/share/examples/gpanel/flappy.c index a05a2f1..25a1006 100644 --- a/share/examples/gpanel/flappy.c +++ b/share/examples/gpanel/flappy.c @@ -1,15 +1,12 @@ #include #include #include +#include +#include #include -#include +#include #include -#ifdef CROSS -# include -# define sgttyb termio -#else -# include -#endif +#include /* * Assign human-readable names to some common 16-bit color values: @@ -343,7 +340,9 @@ void check_collision() } #if 1 +#ifndef SDL struct sgttyb origtty, newtty; +#endif /* * Terminate the game when ^C pressed. @@ -351,8 +350,11 @@ struct sgttyb origtty, newtty; void quit(int sig) { signal(SIGINT, SIG_IGN); +#ifndef SDL if (newtty.sg_flags != 0) ioctl(0, TIOCSETP, &origtty); +#endif + gpanel_close(); exit(0); } @@ -361,6 +363,11 @@ void quit(int sig) */ int get_input() { +#ifdef SDL + extern int gpanel_input(void); + + return gpanel_input(); +#else if (newtty.sg_flags == 0) { ioctl(0, TIOCGETP, &origtty); @@ -377,6 +384,7 @@ int get_input() char c; read(0, &c, 1); return 1; +#endif } #endif