merged a patch from Ricardo Cruz for faster letter loading.
authorTobias Gläßer <tobi.web@gmx.de>
Sat, 21 Feb 2004 00:14:03 +0000 (00:14 +0000)
committerTobias Gläßer <tobi.web@gmx.de>
Sat, 21 Feb 2004 00:14:03 +0000 (00:14 +0000)
SVN-Revision: 136

17 files changed:
data/images/background/arctis.png
data/images/status/checkbox-checked.png
data/images/status/checkbox-checked.xcf
data/images/status/checkbox.png
data/levels/default/level1.dat
src/gameloop.c
src/intro.c
src/menu.c
src/menu.h
src/physic.h
src/player.c
src/screen.c
src/screen.h
src/setup.c
src/text.c
src/text.h
src/title.c

index c5cac49..25503e7 100644 (file)
Binary files a/data/images/background/arctis.png and b/data/images/background/arctis.png differ
index 53d3bab..0859b07 100644 (file)
Binary files a/data/images/status/checkbox-checked.png and b/data/images/status/checkbox-checked.png differ
index d371f8c..1cf785e 100644 (file)
Binary files a/data/images/status/checkbox-checked.xcf and b/data/images/status/checkbox-checked.xcf differ
index d58b1a0..4fbe043 100644 (file)
Binary files a/data/images/status/checkbox.png and b/data/images/status/checkbox.png differ
index 6b38a16..b584e70 100644 (file)
@@ -1,6 +1,6 @@
 Antarctica 1
 antarctica
-255
+100
 Mortimers_chipdisko.mod
 arctis.png
 128
@@ -9,16 +9,16 @@ arctis.png
 375
 ......cdef......2.........................................cdef.........................................................CDEF.....................................cdedef..........................................................CDEF........................................................................cdef..............cf....................................................cde
 .......................................................................................................................cdef.....................................................................................................cdef...................................................................................................................................................
-......................CDEF........................................CDEF.......................................................................CDEF....................................CDEF.......................................................................................................CDEDEF................................................................[.........*......
-......................cdef........................................cdef.......................................................................cdef.............................$......cdef.......................................................................................................cdedef...............................................................[#........\|......
-....................................CDEDEF.................................................................................................................................$....$.............................................................................................CDEF.....................................................0............................[##.........|......
-....................................cdedef...................................................CDEF................0..............................................................CDEF............................................................CDEF..........................cdef............................................###.###..#...........................[###.........|......
-...........................A.................................................................cdef............YYYYYYYY...YYYYYA....................A....................$........cdef............................................................cdef....................................A.....................................#...#.#..#..........................[####.........|.....C
-....................................................................................................................................................................$...0.........$...........................................................................................................................................#.#.#.#............................[#####.........|.....c
-.................................................................................................................................................................$...0###.....................................................................................................................................................#.#.#.#.CDEF......................[######EF.......|......
-..............................................................................................................................................................$...0######...............................[==]................[==...]...........................................................................................###.###.c#ef.....................[#######ef.......|......
-.....................A...XBXAX...........................................[=].................[=]..........XBX................x.........A!......A..A..A.........0#########...........$..................[####]..............[###...#].................XAXXBX....................................$.$.$.$1.......................................................[########.........|......
-............................................................[=]..........###.................###.............................................................############.............................[######]............[####...##]...........###...........###......................[=]....#########....[=]...............................................[#########.........|......
+......................CD#F.#......................................CDEF.......................................................................CDEF....................................CDEF.......................................................................................................CDEDEF................................................................[.........*......
+............XXXX......cdef.##.....................................cdef.......................................................................cdef.............................$......cdef.......................................................................................................cdedef...............................................................[#........\|......
+...XX.XXXXX.....X...................CDEDEF.................................................................................................................................$....$.............................................................................................CDEF.....................................................0............................[##.........|......
+...X.....a.......XX.................cdedef...................................................CDEF................0..............................................................CDEF............................................................CDEF..........................cdef............................................###.###..#...........................[###.........|......
+..X......aaaaa.....X.......A.................................................................cdef............YYYYYYYY...YYYYYA....................A....................$........cdef............................................................cdef....................................A.....................................#...#.#..#..........................[####.........|.....C
+....X........a......XXX.............................................................................................................................................$...0.........$...........................................................................................................................................#.#.#.#............................[#####.........|.....c
+.......A.....aa..................................................................................................................................................$...0###.....................................................................................................................................................#.#.#.#.CDEF......................[######EF.......|......
+..BB.....BB...aa........##....................................................................................................................................$...0######.....0.........................[==]................[==...]...........................................................................................###.###.c#ef.....................[#######ef.......|......
+...........!...a.....A...#####...........................................[=].................[=]..........XBX................x.........A!......A..A..A.........0#########..yyyyy....$..................[####]..............[###...#].................XAXXBX....................................$.$.$.$1.......................................................[########.........|......
+......................#.#.##................................[=]..........###.................###.............................................................############.............................[######]............[####...##]...........###...........###......................[=]....#########....[=]...............................................[#########.........|......
 .....................................GHJ..........[=]......G###..........###....GHIJ.........###.............................................................############............................[########]HIJ.......[#####...###]..........###...........###......................###.................###................GHIJ.......................GHI[##########.........|......
 ..GHIJ...........................0...ghj..........###......g###..GHIJ 0..###....ghij.0.0.0...###.......................GHIJ.........0.0..1.........0.0.......############.............$....0.0.0....[##########]ij......[######...####]...GHIJ..###........0.0###HIJ......1....0.0.0...###...0.0.0.........###................ghij.......................gh[###########==========]^^^^^
 ===================================================================================================]...[=====########..g######===============================############^^^^^^^^^^#######=============================]#######...#####[=================================================]#################[===============================================#######################&&&&&
index ce373b1..581386f 100644 (file)
@@ -624,9 +624,6 @@ int gameloop(char * subset, int levelnb, int mode)
                 case 1:
                   savegame();
                   break;
-                case 2:
-                  loadgame(NULL);
-                  break;
                 case 4:
                   done = 1;
                   break;
index d60f088..bb9f529 100644 (file)
@@ -2,7 +2,7 @@
   intro.c
   
   Super Tux - Intro Screen
-  
+
   by Bill Kendrick
   bill@newbreedsoftware.com
   http://www.newbreedsoftware.com/supertux/
@@ -146,7 +146,7 @@ int intro(void)
          ++scene;
          /* Helicopter begins to fly in: */
          
-         erasecenteredtext(intro_text[0], 454, &bkgd, NO_UPDATE, 1);
+         erasecenteredtext(&white_text, intro_text[0], 454, &bkgd, NO_UPDATE, 1);
          text_drawf(&white_text, intro_text[1], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
        }
 
@@ -200,7 +200,7 @@ int intro(void)
          texture_draw(&tux_upset, 270, 400, UPDATE);
          
          
-         erasecenteredtext(intro_text[1], 454, &bkgd, UPDATE, 1);
+         erasecenteredtext(&white_text, intro_text[1], 454, &bkgd, UPDATE, 1);
          text_drawf(&white_text, intro_text[2], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
        }
       
@@ -254,7 +254,7 @@ int intro(void)
          
          texture_draw(&tux_mad, 270, 400, UPDATE);
          
-         erasecenteredtext(intro_text[2], 454, &bkgd, UPDATE, 1);
+         erasecenteredtext(&white_text, intro_text[2], 454, &bkgd, UPDATE, 1);
          text_drawf(&white_text, intro_text[3], 0,-8, A_HMIDDLE, A_BOTTOM, 0, NO_UPDATE);
        }
       
index e398cfd..bcbbbcb 100644 (file)
@@ -35,9 +35,9 @@
 int menuaction;
 int show_menu;
 int menu_change;
-texture_type checkbox, checkbox_checked;
+texture_type checkbox, checkbox_checked, back;
 
-menu_type main_menu, game_menu, options_menu, leveleditor_menu, highscore_menu;
+menu_type main_menu, game_menu, options_menu, leveleditor_menu, highscore_menu, load_game_menu;
 menu_type* current_menu, * last_menu;
 
 /* input implementation variables */
@@ -160,7 +160,7 @@ void menu_action(menu_type* pmenu)
           if(pmenu->item[pmenu->active_item].kind == MN_TEXTFIELD)
             {
               if(pmenu->item[pmenu->active_item].input != NULL)
-                {      
+                {
                   i = strlen(pmenu->item[pmenu->active_item].input);
                   pmenu->item[pmenu->active_item].input = (char*) realloc(pmenu->item[pmenu->active_item].input,sizeof(char)*(i + 2));
                   pmenu->item[pmenu->active_item].input[i] = mn_input_char;
@@ -176,11 +176,16 @@ void menu_action(menu_type* pmenu)
           break;
         }
     }
-    
-    menuaction = -1;
 
-  if(pmenu->item[pmenu->active_item].kind == MN_DEACTIVE)
-    menu_action(pmenu);
+  if(pmenu->item[pmenu->active_item].kind == MN_DEACTIVE || pmenu->item[pmenu->active_item].kind == MN_LABEL)
+    {
+      if(menuaction != MN_UP && menuaction != MN_DOWN)
+        menuaction = MN_DOWN;
+
+      if(pmenu->num_items > 1)
+        menu_action(pmenu);
+    }
+
 }
 
 /* Check, if the value of the active menu item has changed. */
@@ -214,7 +219,7 @@ void menu_draw(menu_type* pmenu)
   menu_width = 0;
   for(i = 0; i < pmenu->num_items; ++i)
     {
-    y = strlen(pmenu->item[i].text) + (pmenu->item[i].input ? strlen(pmenu->item[i].input) : 0);
+      y = strlen(pmenu->item[i].text) + (pmenu->item[i].input ? strlen(pmenu->item[i].input) : 0);
       if( y > menu_width )
         {
           menu_width = y;
@@ -224,7 +229,7 @@ void menu_draw(menu_type* pmenu)
     }
   menu_width = menu_width * 16 + 48;
   menu_height = (pmenu->num_items) * 24;
-  
+
   /* Draw a transparent background */
   fillrect(screen->w/2 - menu_width/2,screen->h/2-(((pmenu->num_items)*24)/2),menu_width,menu_height,150,150,150,100);
 
@@ -234,6 +239,11 @@ void menu_draw(menu_type* pmenu)
         {
           text_drawf(&black_text,pmenu->item[i].text,0,(i)*24 - menu_height/2 + 10,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
         }
+      else if(pmenu->item[i].kind == MN_LABEL)
+        {
+          text_drawf(&gold_text,pmenu->item[i].text,0,(i)*24 - menu_height/2 + 10,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
+          fillrect(screen->w/2 - menu_width/2,(i)*24 - menu_height/2 + 28,menu_width,2,150,150,150,100);
+        }
       else if(pmenu->item[i].kind == MN_TEXTFIELD)
         {
           text_drawf(&gold_text,pmenu->item[i].input,(strlen(pmenu->item[i].text) * 16)/2,(i)*24 - menu_height/2 + 10,A_HMIDDLE, A_VMIDDLE,2,NO_UPDATE);
@@ -262,6 +272,10 @@ void menu_draw(menu_type* pmenu)
           else
             texture_draw(&checkbox,screen->w / 2 + (strlen(pmenu->item[i].text) * 16)/2 + 16,(i)*24 - menu_height/2 + 10 + screen->h / 2 - 8,NO_UPDATE);
         }
+      else if(pmenu->item[i].kind == MN_BACK)
+      {
+            texture_draw(&back,screen->w / 2 + (strlen(pmenu->item[i].text) * 16)/2  + 16,(i)*24 - menu_height/2 + 10 + screen->h / 2 -8,NO_UPDATE);
+      }
     }
 }
 
@@ -349,8 +363,8 @@ void menu_event(SDL_keysym* keysym)
         }
       else
         {
-        mn_input_char = '\0';
-       }
+          mn_input_char = '\0';
+        }
       break;
     }
 
index edccfb8..ecb86c7 100644 (file)
@@ -50,7 +50,8 @@ enum {
   MN_TOGGLE,
   MN_BACK,
   MN_DEACTIVE,
-  MN_TEXTFIELD
+  MN_TEXTFIELD,
+  MN_LABEL
 };
 
 /* Action done on the menu */
@@ -66,9 +67,9 @@ enum {
 extern int menuaction;
 extern int show_menu;
 extern int menu_change;
-extern texture_type checkbox, checkbox_checked;
+extern texture_type checkbox, checkbox_checked, back;
 
-extern menu_type main_menu, game_menu, options_menu, leveleditor_menu, highscore_menu;
+extern menu_type main_menu, game_menu, options_menu, leveleditor_menu, highscore_menu, load_game_menu;
 extern menu_type* current_menu, * last_menu;
 
 /* input implementation variables */
index fd7f886..17bf686 100644 (file)
@@ -16,7 +16,7 @@
 #include "timer.h"
 
 enum {
-  PH_VT, /* Vertical throw.*/
+  PH_VT /* Vertical throw.*/
 };
 
 /* Physic type: */
index e064bf7..6d42f49 100644 (file)
@@ -170,7 +170,7 @@ void player_action(player_type* pplayer)
   if (!pplayer->dying)
     {
       /* FIXME: this code is COMPLETLY broken!!! */
-        if (issolid(pplayer->base.x, pplayer->base.y + 31) &&
+       /* if (issolid(pplayer->base.x, pplayer->base.y + 31) &&
             !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y + 31))
           {
             while (issolid(pplayer->base.x, pplayer->base.y + 31))
@@ -182,9 +182,9 @@ void player_action(player_type* pplayer)
               }
 
             pplayer->base.xm = 0;
-          }
+          }*/
 
-        if (issolid(pplayer->base.x, pplayer->base.y) &&
+        /*if (issolid(pplayer->base.x, pplayer->base.y) &&
             !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y))
           {
             while (issolid(pplayer->base.x, (pplayer->base.y)))
@@ -196,7 +196,7 @@ void player_action(player_type* pplayer)
               }
 
             pplayer->base.xm = 0;
-          }
+          }*/
 
         if (issolid(pplayer->base.x, pplayer->base.y + 31))
           {
@@ -251,14 +251,12 @@ void player_action(player_type* pplayer)
           pplayer->base.ym = 0;
         }
           
-      if ((!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y) && (issolid(pplayer->base.x, pplayer->base.y) || issolid(pplayer->base.x+32, pplayer->base.y))
-          /*(pplayer->size == SMALL || pplayer->duck ||
-           !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32))*/) || ( pplayer->size == BIG && (
-          (!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y+32) && (issolid(pplayer->base.x, pplayer->base.y+32) || issolid(pplayer->base.x+32, pplayer->base.y+32))
+      if (((issolid(pplayer->base.x, pplayer->base.y) || issolid(pplayer->base.x+32, pplayer->base.y)) &&  (!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y))
           /*(pplayer->size == SMALL || pplayer->duck ||
-           !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32))*/))))
+           !issolid(pplayer->base.x- pplayer->base.xm, pplayer->base.y - 32))*/) || 
+          (!issolid(pplayer->base.x - pplayer->base.xm * frame_ratio, pplayer->base.y+pplayer->base.height) && (issolid(pplayer->base.x, pplayer->base.y+pplayer->base.height) || issolid(pplayer->base.x +32, pplayer->base.y+pplayer->base.height))))
         {
-          pplayer->base.x = pplayer->base.x- pplayer->base.xm * frame_ratio;
+         pplayer->base.x = pplayer->base.x- pplayer->base.xm * frame_ratio;
           pplayer->base.xm = 0;
         }
        
index 5ba08e0..2387b13 100644 (file)
@@ -304,32 +304,3 @@ void update_rect(SDL_Surface *scr, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
     SDL_UpdateRect(scr, x, y, w, h);
 }
 
-
-/* --- ERASE TEXT: --- */
-
-void erasetext(char * text, int x, int y, texture_type * ptexture, int update, int shadowsize)
-{
-  SDL_Rect dest;
-
-
-  dest.x = x;
-  dest.y = y;
-  dest.w = strlen(text) * 16 + shadowsize;
-  dest.h = 17;
-
-  if (dest.w > screen->w)
-    dest.w = screen->w;
-
-  texture_draw_part(ptexture,dest.x,dest.y,dest.x,dest.y,dest.w,dest.h,update);
-
-  if (update == UPDATE)
-    update_rect(screen, dest.x, dest.y, dest.w, dest.h);
-}
-
-
-/* --- ERASE CENTERED TEXT: --- */
-
-void erasecenteredtext(char * text, int y, texture_type * ptexture, int update, int shadowsize)
-{
-  erasetext(text, screen->w / 2 - (strlen(text) * 8), y, ptexture, update, shadowsize);
-}
index a2362d8..b6229b6 100644 (file)
@@ -31,8 +31,6 @@ void fillrect(float x, float y, float w, float h, int r, int g, int b, int a);
 void updatescreen(void);
 void flipscreen(void);
 SDL_Surface * load_image(char * file, int use_alpha);
-void erasetext(char * text, int x, int y, texture_type * surf, int update, int shadowsize);
-void erasecenteredtext(char * text, int y, texture_type * surf, int update, int shadowsize);
 void update_rect(SDL_Surface *scr, Sint32 x, Sint32 y, Sint32 w, Sint32 h);
 
 #endif /*SUPERTUX_SCREEN_H*/
index d2da0b4..d3d54c9 100644 (file)
@@ -168,9 +168,9 @@ char ** dsubdirs(char *rel_path, char* expected_file, int* num)
 
 void free_strings(char **strings, int num)
 {
-int i;
-for(i=0; i < num; ++i)
-free(strings[i]);
+  int i;
+  for(i=0; i < num; ++i)
+    free(strings[i]);
 }
 
 /* --- SETUP --- */
@@ -222,7 +222,7 @@ void st_menu(void)
 
   menu_init(&main_menu);
   menu_additem(&main_menu,menu_item_create(MN_ACTION,"Start Game",0,0));
-  menu_additem(&main_menu,menu_item_create(MN_ACTION,"Load Game",0,0));
+  menu_additem(&main_menu,menu_item_create(MN_GOTO,"Load Game",0,&load_game_menu));
   menu_additem(&main_menu,menu_item_create(MN_GOTO,"Options",0,&options_menu));
   menu_additem(&main_menu,menu_item_create(MN_ACTION,"Level editor",0,0));
   menu_additem(&main_menu,menu_item_create(MN_ACTION,"Quit",0,0));
@@ -249,10 +249,13 @@ void st_menu(void)
   menu_additem(&leveleditor_menu,menu_item_create(MN_ACTION,"Save Level",0,0));
   menu_additem(&leveleditor_menu,menu_item_create(MN_ACTION,"Quit Level Editor",0,0));
 
+  menu_init(&load_game_menu);
+  menu_additem(&load_game_menu,menu_item_create(MN_LABEL,"Load Game",0,0));
+
   menu_init(&game_menu);
   menu_additem(&game_menu,menu_item_create(MN_ACTION,"Return To Game",0,0));
   menu_additem(&game_menu,menu_item_create(MN_ACTION,"Save Game",0,0));
-  menu_additem(&game_menu,menu_item_create(MN_ACTION,"Load Game",0,0));
+  menu_additem(&game_menu,menu_item_create(MN_GOTO,"Load Game",0,&load_game_menu));
   menu_additem(&game_menu,menu_item_create(MN_GOTO,"Options",0,&options_menu));
   menu_additem(&game_menu,menu_item_create(MN_ACTION,"Quit Game",0,0));
 
@@ -324,7 +327,8 @@ void st_general_setup(void)
   /* Load GUI/menu images: */
   texture_load(&checkbox, DATA_PREFIX "/images/status/checkbox.png", USE_ALPHA);
   texture_load(&checkbox_checked, DATA_PREFIX "/images/status/checkbox-checked.png", USE_ALPHA);
-
+  texture_load(&back, DATA_PREFIX "/images/status/back.png", USE_ALPHA);
+  
   /* Set icon image: */
 
   seticon();
@@ -342,12 +346,13 @@ void st_general_free(void)
   text_free(&white_text);
   text_free(&blue_text);
   text_free(&red_text);
-  text_free(&white_small_text); 
-  
+  text_free(&white_small_text);
+
   /* Free GUI/menu images: */
   texture_free(&checkbox);
   texture_free(&checkbox_checked);
-
+  texture_free(&back);
+  
   /* Free menus */
 
   menu_free(&main_menu);
index 81295cf..4b3197a 100644 (file)
@@ -25,22 +25,16 @@ void text_load(text_type* ptext, char* file, int kind, int w, int h)
 
   if(kind == TEXT_TEXT)
     {
-      ptext->chars = (texture_type*) malloc(sizeof(texture_type) * 79);
-      ptext->shadow_chars = (texture_type*) malloc(sizeof(texture_type) * 79);
       mx = 26;
       my = 3;
     }
   else if(kind == TEXT_NUM)
     {
-      ptext->chars = (texture_type*) malloc(sizeof(texture_type) * 10);
-      ptext->shadow_chars = (texture_type*) malloc(sizeof(texture_type) * 10);
       mx = 10;
       my = 1;
     }
   else
     {
-      ptext->chars = NULL;
-      ptext->shadow_chars = NULL;
       mx = 0;
       my = 0;
     }
@@ -48,22 +42,12 @@ void text_load(text_type* ptext, char* file, int kind, int w, int h)
   ptext->w = w;
   ptext->h = h;
 
-  for(y = 0; y < my ; ++y)
-    {
-      for(x = 0; x < mx ; ++x)
-        {
-          texture_load_part(&ptext->chars[y*mx+x],file,x*w,y*h,w,h, USE_ALPHA);
-        }
-    }
+texture_load(&ptext->chars, file, USE_ALPHA);
 
   /* Load shadow font. */
-  for(y = 0; y < my ; ++y)
-    {
-      for(x = 0; x < mx ; ++x)
-        {
          int pixels;
           int i;
-          conv = SDL_DisplayFormatAlpha(ptext->chars[y*mx+x].sdl_surface);
+          conv = SDL_DisplayFormatAlpha(ptext->chars.sdl_surface);
          pixels = conv->w * conv->h;
          SDL_LockSurface(conv);
           for(i = 0; i < pixels; ++i)
@@ -73,10 +57,9 @@ void text_load(text_type* ptext, char* file, int kind, int w, int h)
             }
            SDL_UnlockSurface(conv);
           SDL_SetAlpha(conv, SDL_SRCALPHA, 128);
-          texture_from_sdl_surface(&ptext->shadow_chars[y*mx+x],conv,USE_ALPHA);
-        }
-    }
+          texture_from_sdl_surface(&ptext->shadow_chars,conv,USE_ALPHA);
 
+SDL_FreeSurface(conv); 
 }
 
 void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int update)
@@ -84,38 +67,32 @@ void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int u
   if(text != NULL)
     {
       if(shadowsize != 0)
-        text_draw_chars(ptext,&ptext->shadow_chars[0], text,x+shadowsize,y+shadowsize, update);
+        text_draw_chars(ptext,&ptext->shadow_chars, text,x+shadowsize,y+shadowsize, update);
 
-      text_draw_chars(ptext,ptext->chars, text,x,y, update);
+      text_draw_chars(ptext,&ptext->chars, text,x,y, update);
     }
 }
 
 void text_draw_chars(text_type* ptext, texture_type* pchars, char* text, int x, int y, int update)
 {
   int i,len;
+int w, h;
 
   len = strlen(text);
+  w = ptext->w; h = ptext->h;
 
   if(ptext->kind == TEXT_TEXT)
     {
       for( i = 0; i < len; ++i)
         {
           if( text[i] >= 'A' && text[i] <= 'Z')
-            {
-              texture_draw(&pchars[(int)(text[i] - 'A')],x+i*ptext->w,y,update);
-            }
+        texture_draw_part(pchars, (int)(text[i] - 'A')*w, 0, x+(i*w), y, ptext->w, ptext->h, update);
           else if( text[i] >= 'a' && text[i] <= 'z')
-            {
-              texture_draw(&pchars[(int)(text[i] - 'a') + 26],x+i*ptext->w,y,update);
-            }
+        texture_draw_part(pchars, (int)(text[i] - 'a')*w, h, x+(i*w), y, ptext->w, ptext->h, update);
           else if ( text[i] >= '!' && text[i] <= '9')
-            {
-              texture_draw(&pchars[(int)(text[i] - '!') + 52],x+i*ptext->w,y,update);
-            }
+        texture_draw_part(pchars, (int)(text[i] - '!')*w, h*2, x+(i*w), y, ptext->w, ptext->h, update);
           else if ( text[i] == '?')
-            {
-              texture_draw(&pchars[77],x+i*ptext->w,y,update);
-            }
+        texture_draw_part(pchars, 25*w, h*2, x+(i*w), y, ptext->w, ptext->h, update);
           else if ( text[i] == '\n')
             {
               y += ptext->h + 2;
@@ -127,9 +104,7 @@ void text_draw_chars(text_type* ptext, texture_type* pchars, char* text, int x,
       for( i = 0; i < len; ++i)
         {
           if ( text[i] >= '0' && text[i] <= '9')
-            {
-              texture_draw(&pchars[(int)(text[i] - '0')],x+i*ptext->w,y,update);
-            }
+        texture_draw_part(pchars, (int)(text[i] - '0')*w, 0, x+(i*w), y, w, h, update);
           else if ( text[i] == '\n')
             {
               y += ptext->h + 2;
@@ -160,13 +135,36 @@ void text_free(text_type* ptext)
 {
   int c;
   if(ptext->kind == TEXT_TEXT)
-    {
-      for( c = 0; c < 78; ++c)
-        texture_free(&ptext->chars[c]);
-    }
+        texture_free(&ptext->chars);
   else if(ptext->kind == TEXT_NUM)
-    {
-      for( c = 0; c < 10; ++c)
-        texture_free(&ptext->chars[c]);
-    }
+        texture_free(&ptext->chars);
+}
+
+/* --- ERASE TEXT: --- */
+
+void erasetext(text_type* ptext, char * text, int x, int y, texture_type * ptexture, int update, int shadowsize)
+{
+  SDL_Rect dest;
+
+
+  dest.x = x;
+  dest.y = y;
+  dest.w = strlen(text) * ptext->w + shadowsize;
+  dest.h = ptext->h;
+
+  if (dest.w > screen->w)
+    dest.w = screen->w;
+
+  texture_draw_part(ptexture,dest.x,dest.y,dest.x,dest.y,dest.w,dest.h,update);
+
+  if (update == UPDATE)
+    update_rect(screen, dest.x, dest.y, dest.w, dest.h);
+}
+
+
+/* --- ERASE CENTERED TEXT: --- */
+
+void erasecenteredtext(text_type* ptext, char * text, int y, texture_type * ptexture, int update, int shadowsize)
+{
+  erasetext(ptext, text, screen->w / 2 - (strlen(text) * 8), y, ptexture, update, shadowsize);
 }
index f04ada2..fcde8f6 100644 (file)
@@ -18,8 +18,8 @@
 /* Text type */
 typedef struct text_type
   {
-   texture_type* chars;
-   texture_type* shadow_chars;
+   texture_type chars;
+   texture_type shadow_chars;
    int kind;
    int w;
    int h;
@@ -47,6 +47,8 @@ void text_draw(text_type* ptext, char* text, int x, int y, int shadowsize, int u
 void text_draw_chars(text_type* ptext, texture_type* pchars, char* text, int x, int y, int update);
 void text_drawf(text_type* ptext, char* text, int x, int y, int halign, int valign, int shadowsize, int update);
 void text_free(text_type* ptext);
+void erasetext(text_type* ptext, char * text, int x, int y, texture_type * surf, int update, int shadowsize);
+void erasecenteredtext(text_type* ptext, char * text, int y, texture_type * surf, int update, int shadowsize);
 
 #endif /*SUPERTUX_TEXT_H*/
 
index 57b2503..f6afbcf 100644 (file)
@@ -135,6 +135,17 @@ int title(void)
       sprintf(str, "by %s", hs_name);
       text_drawf(&gold_text, str, 0, -20, A_HMIDDLE, A_BOTTOM, 1, NO_UPDATE);
 
+      /* Animate title screen: */
+
+      pict = (frame / 5) % 3;
+
+      if (pict == 0)
+        texture_draw_part(&title, 560, 270, 560, 270, 80, 75, NO_UPDATE);
+      else if (pict == 1)
+        texture_draw(&anim1, 560, 270, NO_UPDATE);
+      else if (pict == 2)
+        texture_draw(&anim2, 560, 270, NO_UPDATE);
+       
       /* Don't draw menu, if quit is true */
       if(show_menu && !quit)
         menu_process_current();
@@ -220,16 +231,6 @@ int title(void)
         {
           process_options_menu();
         }
-      /* Animate title screen: */
-
-      pict = (frame / 5) % 3;
-
-      if (pict == 0)
-        texture_draw_part(&title, 560, 270, 560, 270, 80, 75, NO_UPDATE);
-      else if (pict == 1)
-        texture_draw(&anim1, 560, 270, NO_UPDATE);
-      else if (pict == 2)
-        texture_draw(&anim2, 560, 270, NO_UPDATE);
 
       flipscreen();