[Tux4kids-commits] r514 - in tuxmath/trunk: data/images/tux src

cheezmeister-guest at alioth.debian.org cheezmeister-guest at alioth.debian.org
Thu Jun 12 01:58:51 UTC 2008


Author: cheezmeister-guest
Date: 2008-06-12 01:58:50 +0000 (Thu, 12 Jun 2008)
New Revision: 514

Added:
   tuxmath/trunk/data/images/tux/bigtux4.png
   tuxmath/trunk/data/images/tux/bigtux5.png
   tuxmath/trunk/data/images/tux/bigtux6.png
   tuxmath/trunk/src/pixels.c
   tuxmath/trunk/src/pixels.h
   tuxmath/trunk/src/pixels.o
Modified:
   tuxmath/trunk/src/SDL_extras.c
   tuxmath/trunk/src/setup.c
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/titlescreen.h
   tuxmath/trunk/src/tuxmath.h
Log:
513 is a lie! This commit contains the easter egg.



Added: tuxmath/trunk/data/images/tux/bigtux4.png
===================================================================
(Binary files differ)


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

Added: tuxmath/trunk/data/images/tux/bigtux5.png
===================================================================
(Binary files differ)


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

Added: tuxmath/trunk/data/images/tux/bigtux6.png
===================================================================
(Binary files differ)


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

Modified: tuxmath/trunk/src/SDL_extras.c
===================================================================
--- tuxmath/trunk/src/SDL_extras.c	2008-06-12 00:07:50 UTC (rev 513)
+++ tuxmath/trunk/src/SDL_extras.c	2008-06-12 01:58:50 UTC (rev 514)
@@ -626,6 +626,7 @@
 //FIXME: everything below is slightly modified code from pixels.c and would do
 //       better to be included as such.
 
+//#if 0 //selectively omit from here to the end of file until pixels.c is in
 
 
 
@@ -643,7 +644,6 @@
 
 
 
-
 /*
   pixels.c
 

Added: tuxmath/trunk/src/pixels.c
===================================================================
--- tuxmath/trunk/src/pixels.c	                        (rev 0)
+++ tuxmath/trunk/src/pixels.c	2008-06-12 01:58:50 UTC (rev 514)
@@ -0,0 +1,257 @@
+/*
+  pixels.c
+
+  For Tux Paint
+  Pixel read/write functions
+
+  Copyright (c) 2002-2006 by Bill Kendrick and others
+  bill at newbreedsoftware.com
+  http://www.newbreedsoftware.com/tuxpaint/
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+  (See COPYING.txt)
+
+  June 14, 2002 - February 17, 2006
+  $Id: pixels.c,v 1.3 2006/08/27 21:00:55 wkendrick Exp $
+*/
+
+#include "pixels.h"
+//#include "compiler.h"
+//#include "debug.h"
+
+/* Draw a single pixel into the surface: */
+void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel)
+{
+  Uint8 *p;
+
+  /* Assuming the X/Y values are within the bounds of this surface... */
+  if (
+      (((unsigned) x < (unsigned) surface->w)
+       && ((unsigned) y < (unsigned) surface->h)))
+  {
+    // Set a pointer to the exact location in memory of the pixel
+    p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start: beginning of RAM */
+		   (y * surface->pitch) +	/* Go down Y lines */
+		   x);		/* Go in X pixels */
+
+
+    /* Set the (correctly-sized) piece of data in the surface's RAM
+     *          to the pixel value sent in: */
+
+    *p = pixel;
+  }
+}
+
+/* Draw a single pixel into the surface: */
+void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel)
+{
+  Uint8 *p;
+
+  /* Assuming the X/Y values are within the bounds of this surface... */
+  if (
+      (((unsigned) x < (unsigned) surface->w)
+       && ((unsigned) y < (unsigned) surface->h)))
+  {
+    // Set a pointer to the exact location in memory of the pixel
+    p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start: beginning of RAM */
+		   (y * surface->pitch) +	/* Go down Y lines */
+		   (x * 2));	/* Go in X pixels */
+
+
+    /* Set the (correctly-sized) piece of data in the surface's RAM
+     *          to the pixel value sent in: */
+
+    *(Uint16 *) p = pixel;
+  }
+}
+
+/* Draw a single pixel into the surface: */
+void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel)
+{
+  Uint8 *p;
+
+  /* Assuming the X/Y values are within the bounds of this surface... */
+  if (
+      (((unsigned) x < (unsigned) surface->w)
+       && ((unsigned) y < (unsigned) surface->h)))
+  {
+    // Set a pointer to the exact location in memory of the pixel
+    p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start: beginning of RAM */
+		   (y * surface->pitch) +	/* Go down Y lines */
+		   (x * 3));	/* Go in X pixels */
+
+
+    /* Set the (correctly-sized) piece of data in the surface's RAM
+     *          to the pixel value sent in: */
+
+    if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
+    {
+      p[0] = (pixel >> 16) & 0xff;
+      p[1] = (pixel >> 8) & 0xff;
+      p[2] = pixel & 0xff;
+    }
+    else
+    {
+      p[0] = pixel & 0xff;
+      p[1] = (pixel >> 8) & 0xff;
+      p[2] = (pixel >> 16) & 0xff;
+    }
+
+  }
+}
+
+/* Draw a single pixel into the surface: */
+void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel)
+{
+  Uint8 *p;
+
+  /* Assuming the X/Y values are within the bounds of this surface... */
+  if (
+      (((unsigned) x < (unsigned) surface->w)
+       && ((unsigned) y < (unsigned) surface->h)))
+  {
+    // Set a pointer to the exact location in memory of the pixel
+    p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start: beginning of RAM */
+		   (y * surface->pitch) +	/* Go down Y lines */
+		   (x * 4));	/* Go in X pixels */
+
+
+    /* Set the (correctly-sized) piece of data in the surface's RAM
+     *          to the pixel value sent in: */
+
+    *(Uint32 *) p = pixel;	// 32-bit display
+  }
+}
+
+/* Get a pixel: */
+Uint32 getpixel8(SDL_Surface * surface, int x, int y)
+{
+  Uint8 *p;
+
+  /* get the X/Y values within the bounds of this surface */
+  if ((unsigned) x < (unsigned) surface->w)
+    x = (x < 0) ? 0 : surface->w - 1;
+  if ((unsigned) y < (unsigned) surface->h)
+    y = (y < 0) ? 0 : surface->h - 1;
+
+  /* Set a pointer to the exact location in memory of the pixel
+     in question: */
+
+  p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start at top of RAM */
+		 (y * surface->pitch) +	/* Go down Y lines */
+		 x);		/* Go in X pixels */
+
+
+  /* Return the correctly-sized piece of data containing the
+   * pixel's value (an 8-bit palette value, or a 16-, 24- or 32-bit
+   * RGB value) */
+
+  return (*p);
+}
+
+/* Get a pixel: */
+Uint32 getpixel16(SDL_Surface * surface, int x, int y)
+{
+  Uint8 *p;
+
+  /* get the X/Y values within the bounds of this surface */
+  if ((unsigned) x < (unsigned) surface->w)
+    x = (x < 0) ? 0 : surface->w - 1;
+  if ((unsigned) y < (unsigned) surface->h)
+    y = (y < 0) ? 0 : surface->h - 1;
+
+  /* Set a pointer to the exact location in memory of the pixel
+     in question: */
+
+  p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start at top of RAM */
+		 (y * surface->pitch) +	/* Go down Y lines */
+		 (x * 2));	/* Go in X pixels */
+
+
+  /* Return the correctly-sized piece of data containing the
+   * pixel's value (an 8-bit palette value, or a 16-, 24- or 32-bit
+   * RGB value) */
+
+  return (*(Uint16 *) p);
+}
+
+/* Get a pixel: */
+Uint32 getpixel24(SDL_Surface * surface, int x, int y)
+{
+  Uint8 *p;
+  Uint32 pixel;
+
+  /* get the X/Y values within the bounds of this surface */
+  if ((unsigned) x < (unsigned) surface->w)
+    x = (x < 0) ? 0 : surface->w - 1;
+  if ((unsigned) y < (unsigned) surface->h)
+    y = (y < 0) ? 0 : surface->h - 1;
+
+  /* Set a pointer to the exact location in memory of the pixel
+     in question: */
+
+  p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start at top of RAM */
+		 (y * surface->pitch) +	/* Go down Y lines */
+		 (x * 3));	/* Go in X pixels */
+
+
+  /* Return the correctly-sized piece of data containing the
+   * pixel's value (an 8-bit palette value, or a 16-, 24- or 32-bit
+   * RGB value) */
+
+  /* Depending on the byte-order, it could be stored RGB or BGR! */
+
+  if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
+    pixel = p[0] << 16 | p[1] << 8 | p[2];
+  else
+    pixel = p[0] | p[1] << 8 | p[2] << 16;
+
+  return pixel;
+}
+
+/* Get a pixel: */
+Uint32 getpixel32(SDL_Surface * surface, int x, int y)
+{
+  Uint8 *p;
+
+  /* get the X/Y values within the bounds of this surface */
+  if ((unsigned) x < (unsigned) surface->w)
+    x = (x < 0) ? 0 : surface->w - 1;
+  if ((unsigned) y < (unsigned) surface->h)
+    y = (y < 0) ? 0 : surface->h - 1;
+
+  /* Set a pointer to the exact location in memory of the pixel
+     in question: */
+
+  p = (Uint8 *) (((Uint8 *) surface->pixels) +	/* Start at top of RAM */
+		 (y * surface->pitch) +	/* Go down Y lines */
+		 (x * 4));	/* Go in X pixels */
+
+
+  /* Return the correctly-sized piece of data containing the
+   * pixel's value (an 8-bit palette value, or a 16-, 24- or 32-bit
+   * RGB value) */
+
+  return *(Uint32 *) p;		// 32-bit display
+}
+
+void (*putpixels[]) (SDL_Surface *, int, int, Uint32) =
+{
+putpixel8, putpixel8, putpixel16, putpixel24, putpixel32};
+
+
+Uint32(*getpixels[])(SDL_Surface *, int, int) =
+{
+getpixel8, getpixel8, getpixel16, getpixel24, getpixel32};

Added: tuxmath/trunk/src/pixels.h
===================================================================
--- tuxmath/trunk/src/pixels.h	                        (rev 0)
+++ tuxmath/trunk/src/pixels.h	2008-06-12 01:58:50 UTC (rev 514)
@@ -0,0 +1,49 @@
+/*
+  pixels.h
+
+  For Tux Paint
+  Pixel read/write functions
+
+  Copyright (c) 2002-2006 by Bill Kendrick and others
+  bill at newbreedsoftware.com
+  http://www.newbreedsoftware.com/tuxpaint/
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+  (See COPYING.txt)
+
+  June 14, 2002 - February 17, 2006
+  $Id: pixels.h,v 1.2 2006/08/27 21:00:55 wkendrick Exp $
+*/
+
+#ifndef PIXELS_H
+#define PIXELS_H
+
+#include "SDL.h"
+
+void putpixel8(SDL_Surface * surface, int x, int y, Uint32 pixel);
+void putpixel16(SDL_Surface * surface, int x, int y, Uint32 pixel);
+void putpixel24(SDL_Surface * surface, int x, int y, Uint32 pixel);
+void putpixel32(SDL_Surface * surface, int x, int y, Uint32 pixel);
+
+extern void (*putpixels[]) (SDL_Surface *, int, int, Uint32);
+
+Uint32 getpixel8(SDL_Surface * surface, int x, int y);
+Uint32 getpixel16(SDL_Surface * surface, int x, int y);
+Uint32 getpixel24(SDL_Surface * surface, int x, int y);
+Uint32 getpixel32(SDL_Surface * surface, int x, int y);
+
+extern Uint32(*getpixels[]) (SDL_Surface *, int, int);
+
+#endif

Added: tuxmath/trunk/src/pixels.o
===================================================================
(Binary files differ)


Property changes on: tuxmath/trunk/src/pixels.o
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: tuxmath/trunk/src/setup.c
===================================================================
--- tuxmath/trunk/src/setup.c	2008-06-12 00:07:50 UTC (rev 513)
+++ tuxmath/trunk/src/setup.c	2008-06-12 01:58:50 UTC (rev 514)
@@ -519,7 +519,7 @@
     //determine the best fullscreen resolution
     int i;
     SDL_Rect** modes = SDL_ListModes(videoInfo->vfmt, SDL_FULLSCREEN | surfaceMode);
-    if (modes != 0 && modes != -1) //if there _is_ a "best" resolution
+    if (modes != 0 && modes != -1) //if there is a "best" resolution
       {
       fs_res_x = modes[0]->w;
       fs_res_y = modes[0]->h;

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2008-06-12 00:07:50 UTC (rev 513)
+++ tuxmath/trunk/src/titlescreen.c	2008-06-12 01:58:50 UTC (rev 514)
@@ -118,15 +118,19 @@
 	 Tuxdest,
 	 Titledest,
          stopRect,
-         Backrect, //location of the background
-         Tuxback,  //the portion of the background actually covered by Tux
-         Titleback,//and that covered by the title
-	 cursor;
+         Backrect,
+         Tuxback,
+         Titleback,
+	 cursor,
+	 beak;
 
 /* The background image scaled to fullscreen dimensions */
 SDL_Surface* scaled_bkgd = NULL;
-/* Set to scaled_bkgd if scaling fullscreen, images[IMG_MENU_BKG] otherwise */
+/* Set to images[IMG_MENU_BKG] if windowed, scaled_bkgd if fullscreen. */
 SDL_Surface* current_bkg = NULL; //DON'T SDL_Free()!
+/* "Easter Egg" cursor */
+SDL_Surface* egg = NULL; 
+int egg_active = 0; //are we currently using the egg cursor?
 
 /* Local function prototypes: */
 void TitleScreen_load_menu(void);
@@ -150,6 +154,7 @@
 int run_custom_menu(void);
 int run_options_menu(void);
 int run_lessons_menu(void);
+int handle_easter_egg(const SDL_Event* evt);
 
 
 
@@ -292,8 +297,8 @@
     Tuxback.y = Tuxdest.y - Backrect.y;
     Tuxdest.w = Tuxback.w = Tux->frame[0]->w;
     Tuxdest.h = Tuxback.h = Tux->frame[0]->h;
+    
 
-
     Titledest.x = screen->w;
     Titledest.y = 10;
     Titleback.x = Titledest.x - Backrect.x;
@@ -354,6 +359,11 @@
   fprintf(stderr, "Tux and Title are in place now\n");
 #endif
 
+  //location of Tux's beak
+  beak.x = Tuxdest.x + 70;
+  beak.y = Tuxdest.y + 60;
+  beak.w = beak.h = 50;
+    
   /* Start playing menu music if desired: */
   if (Opts_MenuMusic())
   {
@@ -420,6 +430,8 @@
     sprintf(fn, "sprites/%s", menu_sprite_files[i]);
     sprite_list[i] = LoadSprite(fn, IMG_ALPHA);
   }
+  egg = LoadImage("title/egg.png", 
+                  IMG_COLORKEY | IMG_NOT_REQUIRED);
   scaled_bkgd = zoom(images[IMG_MENU_BKG], fs_res_x, fs_res_y);
   return 1;
 }
@@ -444,6 +456,7 @@
   FreeSprite(Tux);
   Tux = NULL;
   TitleScreen_unload_menu();
+  SDL_FreeSurface(egg);
   SDL_FreeSurface(scaled_bkgd);
 }
 
@@ -1601,8 +1614,13 @@
           }  /* End of key switch statement */
         }  // End of case SDL_KEYDOWN in outer switch statement
       }  // End event switch statement
+      if (handle_easter_egg(&event) )
+        redraw = 1;
+      else
+        ; //egg_active = 0;
     }  // End SDL_PollEvent while loop
 
+    
 
     // Make sure the menu title is not selected
     if (loc == 0 && title_offset)
@@ -1679,6 +1697,7 @@
 	  SDL_BlitSurface(images[IMG_RIGHT_GRAY], NULL, screen, &right_arrow_rect);
 	}
       }
+      
       SDL_Flip(screen);//SDL_UpdateRect(screen, 0, 0, 0 ,0);
     } else if (old_loc != loc) {
       // This is not a full redraw, but the selected entry did change.
@@ -1785,6 +1804,13 @@
       SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h);
       //SDL_UpdateRect(screen, 0, 0, 0, 0);
     }
+    
+    if (egg_active) { //if we need to, draw the egg cursor
+      SDL_GetMouseState(&cursor.x, &cursor.y);
+      cursor.x -= egg->w / 2; //center vertically
+      SDL_BlitSurface(egg, NULL, screen, &cursor);
+      SDL_UpdateRect(screen, cursor.x, cursor.y, cursor.w, cursor.h);
+    }
 
     /* Wait so we keep frame rate constant: */
     frame_now = SDL_GetTicks();
@@ -2129,10 +2155,17 @@
   Backrect = current_bkg->clip_rect;
   Backrect.x = (screen->w - Backrect.w) / 2;
   Backrect.y = (screen->h - Backrect.h) / 2;
+  
   Titledest.x = 0;
   Titledest.y = 0;
+  
   Tuxdest.x = 0;
   Tuxdest.y = screen->h - Tuxdest.h;
+  
+  beak.x = Tuxdest.x + 70;
+  beak.y = Tuxdest.y + 60;
+  beak.w = beak.h = 50;
+  
   stopRect.x = screen->w - stopRect.w;
   stopRect.y = 0;
 }
@@ -2263,3 +2296,45 @@
   }
 
 }
+
+int handle_easter_egg(const SDL_Event* evt)
+  {
+  static int eggtimer = 0;
+  int tuxframe = Tux->num_frames;
+    
+  if (egg_active) //are we using the egg cursor?
+    {
+    if (eggtimer < SDL_GetTicks() ) //time's up
+      {
+      SDL_ShowCursor(SDL_ENABLE);
+      //SDL_FillRect(screen, &cursor, 0);
+      SDL_BlitSurface(current_bkg, NULL, screen, &Backrect); //cover egg up once more
+      SDL_WarpMouse(cursor.x, cursor.y);
+      SDL_UpdateRect(screen, cursor.x, cursor.y, cursor.w, cursor.h); //egg->x, egg->y, egg->w, egg->h);
+      egg_active = 0;
+      }
+    return 1;
+    }
+  else //if not, see if the user clicked Tux's beak
+    {
+    eggtimer = 0;
+    if (evt->type == SDL_MOUSEBUTTONDOWN &&
+          inRect(beak, evt->button.x, evt->button.y) )
+      {
+      SDL_ShowCursor(SDL_DISABLE);
+      
+      //animate
+      while (tuxframe != 0)
+        {
+        SDL_BlitSurface(Tux->frame[--tuxframe], NULL, screen, &Tuxdest);
+        SDL_UpdateRect(screen, Tuxdest.x, Tuxdest.y, Tuxdest.w, Tuxdest.h);
+        SDL_Delay(GOBBLE_ANIM_MS / Tux->num_frames);
+        }
+      eggtimer = SDL_GetTicks() + EASTER_EGG_MS;
+      egg_active = 1;
+      SDL_WarpMouse(Tuxdest.x + Tuxdest.w / 2, Tuxdest.y + Tuxdest.h - egg->h);
+      }
+    
+    return 0;
+    }
+  }

Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h	2008-06-12 00:07:50 UTC (rev 513)
+++ tuxmath/trunk/src/titlescreen.h	2008-06-12 01:58:50 UTC (rev 514)
@@ -147,8 +147,9 @@
 #define TUX5                            127
 #define TUX6                            130
 
+#define EASTER_EGG_MS  5000 //length of time to replace cursor
+#define GOBBLE_ANIM_MS 1000 //duration of the gobbling animation
 
-
 /********************************/
 /* "Global" Function Prototypes */
 /********************************/

Modified: tuxmath/trunk/src/tuxmath.h
===================================================================
--- tuxmath/trunk/src/tuxmath.h	2008-06-12 00:07:50 UTC (rev 513)
+++ tuxmath/trunk/src/tuxmath.h	2008-06-12 01:58:50 UTC (rev 514)
@@ -42,10 +42,10 @@
 
 //#define NOSOUND
 /* for conditional compilation of debugging output */
-//#define TUXMATH_DEBUG
+#define TUXMATH_DEBUG
 /* for Tim's feedback speed control code           */
 //#define FEEDBACK_DEBUG
-+/* nice inline debugging macro */
+/* nice inline debugging macro */
 #ifdef TUXMATH_DEBUG
 #define tmdprintf(...) printf(__VA_ARGS__)
 #else




More information about the Tux4kids-commits mailing list