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

cheezmeister-guest at alioth.debian.org cheezmeister-guest at alioth.debian.org
Mon Jun 16 22:40:03 UTC 2008


Author: cheezmeister-guest
Date: 2008-06-16 22:40:02 +0000 (Mon, 16 Jun 2008)
New Revision: 524

Modified:
   tuxmath/trunk/src/highscore.c
   tuxmath/trunk/src/titlescreen.c
   tuxmath/trunk/src/titlescreen.h
Log:
Changed references from images[IMG_MENU_BKG] to current_bkg, cleaned up related code

Modified: tuxmath/trunk/src/highscore.c
===================================================================
--- tuxmath/trunk/src/highscore.c	2008-06-16 12:27:57 UTC (rev 523)
+++ tuxmath/trunk/src/highscore.c	2008-06-16 22:40:02 UTC (rev 524)
@@ -166,8 +166,8 @@
     if (diff_level != old_diff_level)
     {
       /* Draw background: */
-      if (images[IMG_MENU_BKG])
-        SDL_BlitSurface( images[IMG_MENU_BKG], NULL, screen, NULL );
+      if (current_bkg)
+        SDL_BlitSurface( current_bkg, NULL, screen, NULL );
       /* FIXME maybe add image of trophy or similar pic */
       /* Draw Tux: */
       if (Tux && Tux->frame[0]) /* make sure sprite has at least one frame */
@@ -383,8 +383,8 @@
 
 
   /* Draw background: */
-  if (images[IMG_MENU_BKG])
-    SDL_BlitSurface(images[IMG_MENU_BKG], NULL, screen, NULL);
+  if (current_bkg)
+    SDL_BlitSurface(current_bkg, NULL, screen, NULL);
 
   /* Red "Stop" circle in upper right corner to go back to main menu: */
   if (images[IMG_STOP])
@@ -524,7 +524,7 @@
             /* Redraw background and shading in area where we drew text last time: */ 
             if (!first_draw)
             {
-              SDL_BlitSurface(images[IMG_MENU_BKG], &redraw_rect, screen, &redraw_rect);
+              SDL_BlitSurface(current_bkg, &redraw_rect, screen, &redraw_rect);
               DrawButton(&redraw_rect, 0, REG_RGBA);
               SDL_UpdateRect(screen,
                              redraw_rect.x,

Modified: tuxmath/trunk/src/titlescreen.c
===================================================================
--- tuxmath/trunk/src/titlescreen.c	2008-06-16 12:27:57 UTC (rev 523)
+++ tuxmath/trunk/src/titlescreen.c	2008-06-16 22:40:02 UTC (rev 524)
@@ -123,9 +123,11 @@
 	 cursor,
 	 beak;
 
+/* The background image scaled to windowed 648x480 */
+SDL_Surface* bkg = NULL;
 /* The background image scaled to fullscreen dimensions */
 SDL_Surface* scaled_bkg = NULL;
-/* Set to images[IMG_MENU_BKG] if windowed, scaled_bkgd if fullscreen. */
+/* Set to bkg if windowed, scaled_bkgd if fullscreen. */
 SDL_Surface* current_bkg = NULL; //DON'T SDL_Free()!
 /* "Easter Egg" cursor */
 SDL_Surface* egg = NULL; 
@@ -255,7 +257,7 @@
   if (screen->flags & SDL_FULLSCREEN)
     current_bkg = scaled_bkg;
   else
-    current_bkg = images[IMG_MENU_BKG];
+    current_bkg = bkg;
   /* Draw background, if it loaded OK: */
   if (current_bkg)
   {
@@ -310,25 +312,9 @@
     {
       start = SDL_GetTicks();
 
-      /*
-      if (inRect(Backrect, Tuxdest.x, Tuxdest.y) &&
-          inRect(Backrect, Tuxdest.x + Tuxdest.w, Tuxdest.y) &&
-          inRect(Backrect, Tuxdest.x, Tuxdest.y + Tuxdest.h) &&
-          inRect(Backrect, Tuxdest.x + Tuxdest.w, Tuxdest.y + Tuxdest.h) )
-        SDL_BlitSurface(images[IMG_MENU_BKG], &Tuxback, screen, &Tuxdest);
-      else
-        SDL_FillRect(screen, &Tuxdest, 0);
-      if (inRect(Backrect, Titledest.x, Titledest.y) &&
-          inRect(Backrect, Titledest.x + Titledest.w, Titledest.y) &&
-          inRect(Backrect, Titledest.x, Titledest.y + Titledest.h) &&
-          inRect(Backrect, Titledest.x + Titledest.w, Titledest.y + Titledest.h) )
-        SDL_BlitSurface(images[IMG_MENU_BKG], &Titleback, screen, &Titledest);
-      else
-        SDL_FillRect(screen, &Titledest, 0);
-      */
-
-      //just draw to the whole screen. Less error prone than the above at the cost of efficiency
-      SDL_FillRect(screen, &screen->clip_rect, 0);
+      //Draw the entire background, over a black screen if necessary
+      if (current_bkg->w != screen->w || current_bkg->h != screen->h)
+        SDL_FillRect(screen, &screen->clip_rect, 0);
       SDL_BlitSurface(current_bkg, NULL, screen, &Backrect);
 
       Tuxdest.y -= Tux->frame[0]->h / (PRE_ANIM_FRAMES * PRE_FRAME_MULT);
@@ -431,7 +417,6 @@
   }
   egg = LoadImage("title/egg.png", 
                   IMG_COLORKEY | IMG_NOT_REQUIRED);
-  //scaled_bkg = zoom(images[IMG_MENU_BKG], fs_res_x, fs_res_y);
   LoadBothBkgds("title/menu_bkg.jpg", &scaled_bkg, &bkg);
   return 1;
 }

Modified: tuxmath/trunk/src/titlescreen.h
===================================================================
--- tuxmath/trunk/src/titlescreen.h	2008-06-16 12:27:57 UTC (rev 523)
+++ tuxmath/trunk/src/titlescreen.h	2008-06-16 22:40:02 UTC (rev 524)
@@ -113,7 +113,7 @@
 //extern TTF_Font  *font;
 extern SDL_Event  event;
 
-SDL_Surface *bkg;
+extern SDL_Surface *current_bkg;
 
 #define MUSIC_FADE_OUT_MS	80
 




More information about the Tux4kids-commits mailing list