[Tux4kids-commits] r598 - in tuxmath/trunk: data/images/sprites data/missions/multiplay src

cheezmeister-guest at alioth.debian.org cheezmeister-guest at alioth.debian.org
Sat Aug 9 03:17:18 UTC 2008


Author: cheezmeister-guest
Date: 2008-08-09 03:17:18 +0000 (Sat, 09 Aug 2008)
New Revision: 598

Added:
   tuxmath/trunk/data/images/sprites/alone0.png
   tuxmath/trunk/data/images/sprites/alone1.png
   tuxmath/trunk/data/images/sprites/aloned.png
   tuxmath/trunk/data/images/sprites/exclamation0.png
   tuxmath/trunk/data/images/sprites/exclamationd.png
   tuxmath/trunk/data/images/sprites/nums0.png
   tuxmath/trunk/data/images/sprites/nums1.png
   tuxmath/trunk/data/images/sprites/nums2.png
   tuxmath/trunk/data/images/sprites/nums3.png
   tuxmath/trunk/data/images/sprites/nums4.png
   tuxmath/trunk/data/images/sprites/nums5.png
   tuxmath/trunk/data/images/sprites/nums6.png
   tuxmath/trunk/data/images/sprites/nums7.png
   tuxmath/trunk/data/images/sprites/numsd.png
Modified:
   tuxmath/trunk/data/missions/multiplay/mpoptions
   tuxmath/trunk/src/SDL_extras.c
   tuxmath/trunk/src/SDL_extras.h
   tuxmath/trunk/src/game.c
   tuxmath/trunk/src/multiplayer.c
   tuxmath/trunk/src/titlescreen.c
Log:
Fleshed out multiplayer code and added menu sprites


Added: tuxmath/trunk/data/images/sprites/alone0.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/alone0.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/alone1.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/alone1.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/aloned.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/aloned.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/exclamation0.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/exclamation0.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/exclamationd.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/exclamationd.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/nums0.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/nums0.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/nums1.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/nums1.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/nums2.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/nums2.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/nums3.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/nums3.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/nums4.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/nums4.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/nums5.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/nums5.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/nums6.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/nums6.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/nums7.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/nums7.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: tuxmath/trunk/data/images/sprites/numsd.png
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/data/images/sprites/numsd.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: tuxmath/trunk/data/missions/multiplay/mpoptions
===================================================================
--- tuxmath/trunk/data/missions/multiplay/mpoptions	2008-08-08 05:28:55 UTC (rev 597)
+++ tuxmath/trunk/data/missions/multiplay/mpoptions	2008-08-09 03:17:18 UTC (rev 598)
@@ -4,5 +4,6 @@
 avg_list_length = 20
 vary_list_length = 1
 comprehensive = 0
+mp_multiplayer = 1
 
 

Modified: tuxmath/trunk/src/SDL_extras.c
===================================================================
--- tuxmath/trunk/src/SDL_extras.c	2008-08-08 05:28:55 UTC (rev 597)
+++ tuxmath/trunk/src/SDL_extras.c	2008-08-09 03:17:18 UTC (rev 598)
@@ -515,8 +515,16 @@
 
 }
 
-//#if 0
 
+int WaitForKeypress(void)
+{
+  SDL_Event evt;
+  while (1)
+    while (SDL_PollEvent(&evt) )
+      if (evt.type == SDL_KEYDOWN)
+        return evt.key.keysym.sym;
+      else SDL_Delay(50);
+}
 /* Swiped shamelessly from TuxPaint
    Based on code from: http://www.codeproject.com/cs/media/imageprocessing4.asp
    copyright 2002 Christian Graus */
@@ -647,6 +655,3 @@
   return s;
 }
 
-
-
-

Modified: tuxmath/trunk/src/SDL_extras.h
===================================================================
--- tuxmath/trunk/src/SDL_extras.h	2008-08-08 05:28:55 UTC (rev 597)
+++ tuxmath/trunk/src/SDL_extras.h	2008-08-09 03:17:18 UTC (rev 598)
@@ -35,6 +35,7 @@
 int  inRect(SDL_Rect r, int x, int y);
 void DarkenScreen(Uint8 bits);
 void SwitchScreenMode(void);
+int WaitForKeypress(void);
 SDL_Surface* Blend(SDL_Surface *S1, SDL_Surface *S2,float gamma);
 SDL_Surface *zoom(SDL_Surface * src, int new_w, int new_h);
 

Modified: tuxmath/trunk/src/game.c
===================================================================
--- tuxmath/trunk/src/game.c	2008-08-08 05:28:55 UTC (rev 597)
+++ tuxmath/trunk/src/game.c	2008-08-09 03:17:18 UTC (rev 598)
@@ -2180,7 +2180,7 @@
                0);
   
   /* Draw other players' scores */
-  if (mp_get_param(PLAYERS) )
+  if (mp_get_param(PLAYERS) && mp_get_param(MODE) == SCORE_SWEEP )
   {
     for (i = 0; i < mp_get_param(PLAYERS); ++i)
     {

Modified: tuxmath/trunk/src/multiplayer.c
===================================================================
--- tuxmath/trunk/src/multiplayer.c	2008-08-08 05:28:55 UTC (rev 597)
+++ tuxmath/trunk/src/multiplayer.c	2008-08-09 03:17:18 UTC (rev 598)
@@ -68,12 +68,13 @@
       if (result == GAME_OVER_LOST || result == GAME_OVER_ESCAPE)
       {
         //eliminate player
-        pnames[currentplayer] = NULL;
+        pscores[currentplayer] = 0xbeef;
         winners[--activeplayers] = currentplayer;
       }
 
-      while (pnames[currentplayer++] == NULL) //skip over eliminated players
+      while (pscores[currentplayer] == 0xbeef) //skip over eliminated players
       {
+        ++currentplayer;
         currentplayer %= params[PLAYERS];
         if (currentplayer == 0)
           ++round;
@@ -81,6 +82,7 @@
       if (activeplayers <= 1) //last man standing!
       {
 //        showWinners(winners, params[PLAYERS]);
+        tmdprintf("%d wins\n", currentplayer);
         winners[0] = currentplayer;
         done = 1;
       }
@@ -91,7 +93,7 @@
     int hiscore = 0;
     int currentwinner = -1;
 
-    for (round = 1; round < params[ROUNDS]; ++round)
+    for (round = 1; round <= params[ROUNDS]; ++round)
     {
       for (currentplayer = 0; currentplayer < params[PLAYERS]; ++currentplayer)
       {
@@ -125,10 +127,12 @@
 {
   return pscores[playernum];
 }
+
 const char* mp_get_player_name(int playernum)
 {
   return pnames[playernum];
 }
+
 int mp_get_param(int p)
 {
   if (p < 0 || p > NUM_PARAMS)
@@ -142,37 +146,43 @@
 
 void showWinners(int* winners, int num)
 {
-  int i;
+  int skip = 0;
   const int boxspeed = 3;
   char text[HIGH_SCORE_NAME_LENGTH + strlen(" wins!")];
   SDL_Rect box = {screen->w / 2, screen->h / 2, 0, 0};
   SDL_Rect center = box;
   SDL_Event evt;
 
+  tmdprintf(pnames[winners[0]] );
   tmdprintf("%d\n", snprintf(text, HIGH_SCORE_NAME_LENGTH + strlen(" wins!"),
                     "%s wins!", pnames[winners[0]]) );
-  printf("Win text: %s\n", text);
+  tmdprintf("Win text: %s\n", text);
 
+  DarkenScreen(1);
+
   while (box.h < screen->h || box.w < screen->w)
   {
     box.x -= boxspeed;
     box.y -= boxspeed;
     box.h += boxspeed * 2;
     box.w += boxspeed * 2;
-    SDL_FillRect(screen, &box, SDL_MapRGB(screen->format, 0, 0, 0) );
-    DarkenScreen(3);
+
+    SDL_FillRect(screen, &box, 0);
     draw_text(text, center);
     SDL_UpdateRect(screen, box.x, box.y, box.w, box.h);
+
+    while (SDL_PollEvent(&evt) )
+      if (evt.type == SDL_KEYDOWN && evt.key.keysym.sym == SDLK_ESCAPE)
+        skip = 1;
+    if (skip)
+      break;
     SDL_Delay(50);
   }
 
+  SDL_FillRect(screen, NULL, 0);
+  draw_text(text, center);
   SDL_Flip(screen);
-  while (1)
-    while (SDL_PollEvent(&evt) )
-      if (evt.type == SDL_KEYDOWN)
-        return;
-      else
-        SDL_Delay(50);
+  WaitForKeypress();
 }
 
 int initMP()

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2008-08-08 05:28:55 UTC (rev 597)
+++ tuxmath/trunk/src/titlescreen.c	2008-08-09 03:17:18 UTC (rev 598)
@@ -88,6 +88,8 @@
   SPRITE_ALONE,
   SPRITE_FRIENDS,
   SPRITE_CAMPAIGN,
+  SPRITE_SSWEEP,
+  SPRITE_ELIMINATION,
   N_SPRITES};
 
 const unsigned char* menu_sprite_files[N_SPRITES] =
@@ -107,9 +109,11 @@
   "no_goldstar",
   "trophy",
   "credits",
-  "alone", //TODO give these two their own sprites
-  "tux_config_brown",
-  "tux_helmet_red"
+  "alone", 
+  "tux_config_brown", //TODO give these two their own sprites
+  "tux_helmet_red",
+  "nums",
+  "exclamation"
 };
 
 sprite **sprite_list = NULL;
@@ -790,6 +794,10 @@
   sprite* modesprites[3] = {NULL, NULL, NULL};
   sprite* diffsprites[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
   // Set up the sprites
+  modesprites[0] = sprite_list[SPRITE_SSWEEP];
+  modesprites[1] = sprite_list[SPRITE_ELIMINATION];
+  modesprites[2] = sprite_list[SPRITE_MAIN];
+  
   diffsprites[0] = sprite_list[SPRITE_CADET];
   diffsprites[1] = sprite_list[SPRITE_SCOUT];
   diffsprites[2] = sprite_list[SPRITE_RANGER];
@@ -814,11 +822,11 @@
       break;
 
     //ask how many players
-    while (nplayers <= 0)
+    while (nplayers <= 0 || nplayers > MAX_PLAYERS)
     {
       NameEntry(npstr, "How many kids are playing?",
                        "(Between 2 and 4 players)");
-      nplayers = 2;// atoi(npstr);
+      nplayers = atoi(npstr);
     }
 
 
@@ -836,6 +844,7 @@
 int run_activities_menu(void)
 {
   NotImplemented();
+  return 0;
 }
 
 int run_arcade_menu(void)




More information about the Tux4kids-commits mailing list