- fixed some align problems with tux
authorIngo Ruhnke <grumbel@gmx.de>
Sun, 18 Apr 2004 21:16:53 +0000 (21:16 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Sun, 18 Apr 2004 21:16:53 +0000 (21:16 +0000)
- fixed bug in tilemap resize

SVN-Revision: 562

data/supertux.strf
src/level.cpp
src/player.cpp
src/player.h
src/resources.cpp

index 56414cd..0805cda 100644 (file)
 
 
   (sprite (name "largetux-walk-left")
 
 
   (sprite (name "largetux-walk-left")
+          (x-hotspot 6)
+          (y-hotspot 2)
           (images "shared/largetux-walk-left-0.png"
                   "shared/largetux-walk-left-1.png"
                   "shared/largetux-walk-left-2.png"
           (images "shared/largetux-walk-left-0.png"
                   "shared/largetux-walk-left-1.png"
                   "shared/largetux-walk-left-2.png"
                   "shared/largetux-walk-left-5.png"))
 
   (sprite (name "largetux-walk-right")
                   "shared/largetux-walk-left-5.png"))
 
   (sprite (name "largetux-walk-right")
+          (x-hotspot 6)
+          (y-hotspot 2)
           (images "shared/largetux-walk-right-0.png"
                   "shared/largetux-walk-right-1.png"
                   "shared/largetux-walk-right-2.png"
           (images "shared/largetux-walk-right-0.png"
                   "shared/largetux-walk-right-1.png"
                   "shared/largetux-walk-right-2.png"
                   "shared/largetux-walk-right-5.png"))
 
   (sprite (name "largetux-jump-left")
                   "shared/largetux-walk-right-5.png"))
 
   (sprite (name "largetux-jump-left")
+          (x-hotspot 9)
+          (y-hotspot 2)
           (images "shared/largetux-jump-left-0.png"))
           (images "shared/largetux-jump-left-0.png"))
-
   (sprite (name "largetux-jump-right")
   (sprite (name "largetux-jump-right")
+          (x-hotspot 9)
+          (y-hotspot 2)
           (images "shared/largetux-jump-right-0.png"))
 
           (images "shared/largetux-jump-right-0.png"))
 
+
+  (sprite (name "largetux-duck-left")
+          (x-hotspot 6)
+          (y-hotspot 2)
+          (images "shared/tux-duck-left.png"))
+  (sprite (name "largetux-duck-right")
+          (x-hotspot 6)
+          (y-hotspot 6)
+          (images "shared/tux-duck-right.png"))
 )
 
 ;; EOF ;;
 )
 
 ;; EOF ;;
index 970c7b0..b83bdb4 100644 (file)
@@ -289,12 +289,15 @@ Level::load(const std::string& filename)
       reader.read_int("version",  &version);
       reader.read_int("width",  &width);
       reader.read_int("time",  &time_left);
       reader.read_int("version",  &version);
       reader.read_int("width",  &width);
       reader.read_int("time",  &time_left);
+
       reader.read_int("bkgd_top_red",  &bkgd_top.red);
       reader.read_int("bkgd_top_green",  &bkgd_top.green);
       reader.read_int("bkgd_top_blue",  &bkgd_top.blue);
       reader.read_int("bkgd_top_red",  &bkgd_top.red);
       reader.read_int("bkgd_top_green",  &bkgd_top.green);
       reader.read_int("bkgd_top_blue",  &bkgd_top.blue);
+
       reader.read_int("bkgd_bottom_red",  &bkgd_bottom.red);
       reader.read_int("bkgd_bottom_green",  &bkgd_bottom.green);
       reader.read_int("bkgd_bottom_blue",  &bkgd_bottom.blue);
       reader.read_int("bkgd_bottom_red",  &bkgd_bottom.red);
       reader.read_int("bkgd_bottom_green",  &bkgd_bottom.green);
       reader.read_int("bkgd_bottom_blue",  &bkgd_bottom.blue);
+
       reader.read_float("gravity",  &gravity);
       reader.read_string("name",  &name);
       reader.read_string("author", &author);
       reader.read_float("gravity",  &gravity);
       reader.read_string("name",  &name);
       reader.read_string("author", &author);
@@ -597,19 +600,6 @@ Level::load_image(Surface** ptexture, string theme,const  char * file, int use_a
   *ptexture = new Surface(fname, use_alpha);
 }
 
   *ptexture = new Surface(fname, use_alpha);
 }
 
-void tilemap_change_size(unsigned int** tilemap[15], int w, int old_w)
-{
-  int j,y;
-  for(y = 0; y < 15; ++y)
-    {
-      *tilemap[y] = (unsigned int*) realloc(*tilemap[y],(w+1)*sizeof(unsigned int));
-      if(w > old_w)
-        for(j = 0; j < w - old_w; ++j)
-          *tilemap[y][old_w+j] = 0;
-      *tilemap[y][w] = 0;
-    }
-}
-
 /* Change the size of a level (width) */
 void 
 Level::change_size (int new_width)
 /* Change the size of a level (width) */
 void 
 Level::change_size (int new_width)
@@ -617,9 +607,12 @@ Level::change_size (int new_width)
   if(new_width < 21)
     new_width = 21;
 
   if(new_width < 21)
     new_width = 21;
 
-  tilemap_change_size((unsigned int***)&ia_tiles, new_width, width);
-  tilemap_change_size((unsigned int***)&bg_tiles, new_width, width);
-  tilemap_change_size((unsigned int***)&fg_tiles, new_width, width);
+  for(int y = 0; y < 15; ++y)
+    {
+      ia_tiles[y].resize(new_width, 0);
+      bg_tiles[y].resize(new_width, 0);
+      fg_tiles[y].resize(new_width, 0);
+    }
 
   width = new_width;
 }
 
   width = new_width;
 }
index d45be28..cc50bdd 100644 (file)
@@ -32,8 +32,8 @@ Sprite* bigtux_right;
 Sprite* bigtux_left;
 Sprite* bigtux_right_jump;
 Sprite* bigtux_left_jump;
 Sprite* bigtux_left;
 Sprite* bigtux_right_jump;
 Sprite* bigtux_left_jump;
-Surface* ducktux_right;
-Surface* ducktux_left;
+Sprite* ducktux_right;
+Sprite* ducktux_left;
 Surface* skidtux_right;
 Surface* skidtux_left;
 Surface* firetux_right[3];
 Surface* skidtux_right;
 Surface* skidtux_left;
 Surface* firetux_right[3];
@@ -517,14 +517,9 @@ Player::draw()
               /* Draw cape: */
 
               if (dir == RIGHT)
               /* Draw cape: */
 
               if (dir == RIGHT)
-                {
-                 cape_right[global_frame_counter % 2]->draw(base.x- scroll_x, base.y);
-                }
+                cape_right[global_frame_counter % 2]->draw(base.x- scroll_x, base.y);
               else
               else
-                {
-                  cape_left[global_frame_counter % 2]->draw(
-                               base.x- scroll_x, base.y);
-                }
+                cape_left[global_frame_counter % 2]->draw(base.x- scroll_x, base.y);
             }
 
 
             }
 
 
@@ -549,11 +544,9 @@ Player::draw()
                   else // moving
                     {
                       if (dir == RIGHT)
                   else // moving
                     {
                       if (dir == RIGHT)
-                        tux_right[(global_frame_counter/2) % tux_right.size()]->draw( 
-                                     base.x - scroll_x, base.y - 9);
+                        tux_right[(global_frame_counter/2) % tux_right.size()]->draw(base.x - scroll_x, base.y - 9);
                       else
                       else
-                        tux_left[(global_frame_counter/2) % tux_left.size()]->draw( 
-                                     base.x - scroll_x, base.y - 9);
+                        tux_left[(global_frame_counter/2) % tux_left.size()]->draw(base.x - scroll_x, base.y - 9);
                     }
                 }
             }
                     }
                 }
             }
@@ -581,15 +574,9 @@ Player::draw()
                 
               /* Draw cape (just not in ducked mode since that looks silly): */
               if (dir == RIGHT)
                 
               /* Draw cape (just not in ducked mode since that looks silly): */
               if (dir == RIGHT)
-                {
-                  bigcape_right[global_frame_counter % 2]->draw(
-                          capex, capey);
-                }
+                bigcape_right[global_frame_counter % 2]->draw(capex, capey);
               else
               else
-                {
-                  bigcape_left[global_frame_counter % 2]->draw(
-                          capex, capey);
-                }
+                bigcape_left[global_frame_counter % 2]->draw(capex, capey);
             }
 
           if (!got_coffee)
             }
 
           if (!got_coffee)
@@ -601,36 +588,32 @@ Player::draw()
                       if (physic.get_velocity_y() == 0)
                         {
                           if (dir == RIGHT)
                       if (physic.get_velocity_y() == 0)
                         {
                           if (dir == RIGHT)
-                            bigtux_right->draw(base.x- scroll_x - 8, base.y);
+                            bigtux_right->draw(base.x - scroll_x, base.y);
                           else
                           else
-                              bigtux_left->draw(base.x- scroll_x - 8, base.y);
+                            bigtux_left->draw(base.x - scroll_x, base.y);
                         }
                       else
                         {
                           if (dir == RIGHT)
                         }
                       else
                         {
                           if (dir == RIGHT)
-                            bigtux_right_jump->draw(base.x- scroll_x - 8, base.y);
+                            bigtux_right_jump->draw(base.x - scroll_x, base.y);
                           else
                           else
-                            bigtux_left_jump->draw(base.x- scroll_x - 8, base.y);
+                            bigtux_left_jump->draw(base.x - scroll_x, base.y);
                         }
                     }
                   else
                     {
                       if (dir == RIGHT)
                         }
                     }
                   else
                     {
                       if (dir == RIGHT)
-                        skidtux_right->draw(base.x- scroll_x - 8, base.y);
+                        skidtux_right->draw(base.x - scroll_x - 8, base.y);
                       else
                       else
-                        skidtux_left->draw(base.x- scroll_x - 8, base.y);
+                        skidtux_left->draw(base.x - scroll_x - 8, base.y);
                     }
                 }
               else
                 {
                   if (dir == RIGHT)
                     }
                 }
               else
                 {
                   if (dir == RIGHT)
-                    {
-                      ducktux_right->draw( base.x- scroll_x - 8, base.y - 16);
-                    }
+                    ducktux_right->draw(base.x - scroll_x, base.y);
                   else
                   else
-                    {
-                      ducktux_left->draw( base.x- scroll_x - 8, base.y - 16);
-                    }
+                    ducktux_left->draw(base.x - scroll_x, base.y);
                 }
             }
           else
                 }
             }
           else
@@ -643,54 +626,32 @@ Player::draw()
                       if (!jumping || physic.get_velocity_y() > 0)
                         {
                           if (dir == RIGHT)
                       if (!jumping || physic.get_velocity_y() > 0)
                         {
                           if (dir == RIGHT)
-                            {
-                              bigfiretux_right[frame_]->draw(
-                                           base.x- scroll_x - 8, base.y);
-                            }
+                            bigfiretux_right[frame_]->draw(base.x- scroll_x - 8, base.y);
                           else
                           else
-                            {
-                              bigfiretux_left[frame_]->draw(
-                                           base.x- scroll_x - 8, base.y);
-                            }
+                            bigfiretux_left[frame_]->draw(base.x- scroll_x - 8, base.y);
                         }
                       else
                         {
                           if (dir == RIGHT)
                         }
                       else
                         {
                           if (dir == RIGHT)
-                            {
-                              bigfiretux_right_jump->draw(
-                                           base.x- scroll_x - 8, base.y);
-                            }
+                            bigfiretux_right_jump->draw(base.x- scroll_x - 8, base.y);
                           else
                           else
-                            {
-                              bigfiretux_left_jump->draw(
-                                           base.x- scroll_x - 8, base.y);
-                            }
+                            bigfiretux_left_jump->draw(base.x- scroll_x - 8, base.y);
                         }
                     }
                   else
                     {
                       if (dir == RIGHT)
                         }
                     }
                   else
                     {
                       if (dir == RIGHT)
-                        {
-                          skidfiretux_right->draw(
-                                       base.x- scroll_x - 8, base.y);
-                        }
+                        skidfiretux_right->draw(base.x- scroll_x - 8, base.y);
                       else
                       else
-                        {
-                          skidfiretux_left->draw(
-                                       base.x- scroll_x - 8, base.y);
-                        }
+                        skidfiretux_left->draw(base.x- scroll_x - 8, base.y);
                     }
                 }
               else
                 {
                   if (dir == RIGHT)
                     }
                 }
               else
                 {
                   if (dir == RIGHT)
-                    {
-                      duckfiretux_right->draw( base.x- scroll_x - 8, base.y - 16);
-                    }
+                    duckfiretux_right->draw( base.x- scroll_x - 8, base.y - 16);
                   else
                   else
-                    {
-                      duckfiretux_left->draw( base.x- scroll_x - 8, base.y - 16);
-                    }
+                    duckfiretux_left->draw( base.x- scroll_x - 8, base.y - 16);
                 }
             }
         }
                 }
             }
         }
index c134427..49e7ec1 100644 (file)
@@ -73,8 +73,8 @@ extern Sprite* bigtux_right;
 extern Sprite* bigtux_left;
 extern Sprite* bigtux_right_jump;
 extern Sprite* bigtux_left_jump;
 extern Sprite* bigtux_left;
 extern Sprite* bigtux_right_jump;
 extern Sprite* bigtux_left_jump;
-extern Surface* ducktux_right;
-extern Surface* ducktux_left;
+extern Sprite* ducktux_right;
+extern Sprite* ducktux_left;
 extern Surface* skidtux_right;
 extern Surface* skidtux_left;
 extern Surface* firetux_right[3];
 extern Surface* skidtux_right;
 extern Surface* skidtux_left;
 extern Surface* firetux_right[3];
index 397b74b..9581d36 100644 (file)
@@ -128,13 +128,8 @@ void loadshared()
                USE_ALPHA);
 
 
                USE_ALPHA);
 
 
-  ducktux_right = new Surface(datadir +
-               "/images/shared/tux-duck-right.png",
-               USE_ALPHA);
-
-  ducktux_left = new Surface(datadir +
-               "/images/shared/tux-duck-left.png",
-               USE_ALPHA);
+  ducktux_left  = sprite_manager->load("largetux-duck-left");
+  ducktux_right = sprite_manager->load("largetux-duck-right");
 
   skidtux_right = new Surface(datadir +
                "/images/shared/skidtux-right.png",
 
   skidtux_right = new Surface(datadir +
                "/images/shared/skidtux-right.png",