[Tux4kids-commits] r949 - tuxmath/trunk/src

cheezmeister-guest at alioth.debian.org cheezmeister-guest at alioth.debian.org
Wed Apr 1 03:42:36 UTC 2009


Author: cheezmeister-guest
Date: 2009-04-01 03:42:36 +0000 (Wed, 01 Apr 2009)
New Revision: 949

Modified:
   tuxmath/trunk/src/game.c
   tuxmath/trunk/src/game.h
Log:
Reworking of game exit conditions to allow 'cheating' 

Modified: tuxmath/trunk/src/game.c
===================================================================
--- tuxmath/trunk/src/game.c	2009-03-27 16:38:46 UTC (rev 948)
+++ tuxmath/trunk/src/game.c	2009-04-01 03:42:36 UTC (rev 949)
@@ -79,8 +79,7 @@
 
 static int gameover_counter;
 static int game_status;
-static int SDL_quit_received;
-static int escape_received;
+static int user_quit_received;
 static int paused;
 static int wave;
 static int score;
@@ -489,8 +488,7 @@
 
   game_status = GAME_IN_PROGRESS;
   gameover_counter = -1;
-  SDL_quit_received = 0;
-  escape_received = 0;
+  user_quit_received = 0;
 
   /* Start MathCards backend: */
   /* FIXME may need to move this into tuxmath.c to accomodate option */
@@ -980,7 +978,7 @@
   {
     if (event.type == SDL_QUIT)
     {
-      SDL_quit_received = 1;
+      user_quit_received = GAME_OVER_WINDOW_CLOSE;
     }
     else if (event.type == SDL_KEYDOWN)
     {
@@ -2218,17 +2216,19 @@
 
 int check_exit_conditions(void)
 {
-  if (SDL_quit_received)
+  if (user_quit_received)
   {
-    return GAME_OVER_WINDOW_CLOSE;
+    if (user_quit_received != GAME_OVER_WINDOW_CLOSE &&
+        user_quit_received != GAME_OVER_ESCAPE &&
+        user_quit_received != GAME_OVER_CHEATER)
+    {
+    	 tmdprintf("Unexpected value %d for user_quit_received\n", user_quit_received);
+    	 return GAME_OVER_OTHER;
+    }
+    return user_quit_received;    
   }
 
-  if (escape_received)
-  {
-    return GAME_OVER_ESCAPE;
-  }
-
-  /* determine if game lost (i.e. all cities blown up): */
+  /* determine if game lost (i.e. all igloos melted): */
   if (!num_cities_alive)
   {
     if (gameover_counter < 0)
@@ -2793,8 +2793,8 @@
         pause_done = 1;
       else if (event.type == SDL_QUIT)
       {
-        SDL_quit_received = 1;
-         pause_quit = 1;
+        user_quit_received = GAME_OVER_WINDOW_CLOSE;
+        pause_quit = 1;
       }
     }
 
@@ -3229,9 +3229,14 @@
   if (key == SDLK_ESCAPE)
   {
     /* Escape key - quit! */
-    escape_received = 1;
+    user_quit_received = GAME_OVER_ESCAPE;
   }
-
+#ifdef TUXMATH_DEBUG
+  if (key == SDLK_LEFTBRACKET) //a nice nonobvious/unused key
+  {
+    user_quit_received = GAME_OVER_CHEATER;
+  }
+#endif
   else if (key == SDLK_TAB
         || key == SDLK_p)
   {

Modified: tuxmath/trunk/src/game.h
===================================================================
--- tuxmath/trunk/src/game.h	2009-03-27 16:38:46 UTC (rev 948)
+++ tuxmath/trunk/src/game.h	2009-04-01 03:42:36 UTC (rev 949)
@@ -97,6 +97,7 @@
   GAME_OVER_OTHER,
   GAME_OVER_ESCAPE,
   GAME_OVER_WINDOW_CLOSE,
+  GAME_OVER_CHEATER,
   GAME_OVER_ERROR
 };
 




More information about the Tux4kids-commits mailing list