- moved tux gfx into a struct
authorIngo Ruhnke <grumbel@gmx.de>
Sun, 25 Apr 2004 16:17:18 +0000 (16:17 +0000)
committerIngo Ruhnke <grumbel@gmx.de>
Sun, 25 Apr 2004 16:17:18 +0000 (16:17 +0000)
SVN-Revision: 709

src/leveleditor.cpp
src/player.cpp
src/player.h
src/resources.cpp

index 657ed3b..f79890b 100644 (file)
@@ -779,7 +779,7 @@ void le_drawlevel()
 
   /* Draw the player: */
   /* for now, the position is fixed at (100, 240) */
-  largetux_walk_right->draw( 100 - pos_x, 240);
+  largetux.walk_right->draw( 100 - pos_x, 240);
 }
 
 void le_checkevents()
index 9186fed..479c5ca 100644 (file)
@@ -34,33 +34,8 @@ Sprite* smalltux_gameover;
 Sprite* smalltux_star;
 Sprite* largetux_star;
 
-Sprite* smalltux_stand_left;
-Sprite* smalltux_stand_right;
-Sprite* smalltux_walk_right;
-Sprite* smalltux_walk_left;
-Sprite* smalltux_jump_left;
-Sprite* smalltux_jump_right;
-Sprite* smalltux_kick_left;
-Sprite* smalltux_kick_right;
-Sprite* smalltux_skid_left;
-Sprite* smalltux_skid_right;
-Sprite* smalltux_grab_left;
-Sprite* smalltux_grab_right;
-
-Sprite* largetux_stand_left;
-Sprite* largetux_stand_right;
-Sprite* largetux_walk_right;
-Sprite* largetux_walk_left;
-Sprite* largetux_jump_right;
-Sprite* largetux_jump_left;
-Sprite* largetux_kick_left;
-Sprite* largetux_kick_right;
-Sprite* largetux_skid_right;
-Sprite* largetux_skid_left;
-Sprite* largetux_grab_left;
-Sprite* largetux_grab_right;
-Sprite* largetux_duck_right;
-Sprite* largetux_duck_left;
+PlayerSprite smalltux;
+PlayerSprite largetux;
 
 Surface* firetux_right[3];
 Surface* firetux_left[3];
@@ -538,42 +513,42 @@ Player::draw()
                   if (physic.get_velocity_y() != 0)
                     {
                       if (dir == RIGHT)
-                        smalltux_jump_right->draw(base.x - scroll_x, base.y);
+                        smalltux.jump_right->draw(base.x - scroll_x, base.y);
                       else
-                        smalltux_jump_left->draw(base.x - scroll_x, base.y);                   
+                        smalltux.jump_left->draw(base.x - scroll_x, base.y);                   
                     }
                   else
                     {
                       if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
                         {
                           if (dir == RIGHT)
-                            smalltux_stand_right->draw( base.x - scroll_x, base.y - 9);
+                            smalltux.stand_right->draw( base.x - scroll_x, base.y - 9);
                           else
-                            smalltux_stand_left->draw( base.x - scroll_x, base.y - 9);
+                            smalltux.stand_left->draw( base.x - scroll_x, base.y - 9);
                         }
                       else // moving
                         {
                           if (dir == RIGHT)
-                            smalltux_walk_right->draw(base.x - scroll_x, base.y);
+                            smalltux.walk_right->draw(base.x - scroll_x, base.y);
                           else
-                            smalltux_walk_left->draw(base.x - scroll_x, base.y);
+                            smalltux.walk_left->draw(base.x - scroll_x, base.y);
                         }
                     }
                 }
               else
                 {
                   if (dir == RIGHT)
-                    smalltux_skid_right->draw(base.x - scroll_x, base.y);
+                    smalltux.skid_right->draw(base.x - scroll_x, base.y);
                   else
-                    smalltux_skid_left->draw(base.x - scroll_x, base.y); 
+                    smalltux.skid_left->draw(base.x - scroll_x, base.y); 
                 }
 
               if (holding_something && physic.get_velocity_y() == 0)
                 {
                   if (dir == RIGHT)
-                    smalltux_grab_right->draw(base.x - scroll_x, base.y);
+                    smalltux.grab_right->draw(base.x - scroll_x, base.y);
                   else
-                    smalltux_grab_left->draw(base.x - scroll_x, base.y);
+                    smalltux.grab_left->draw(base.x - scroll_x, base.y);
                 }
 
               if (invincible_timer.started())
@@ -592,40 +567,40 @@ Player::draw()
                               if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
                                 {
                                   if (dir == RIGHT)
-                                    largetux_stand_right->draw(base.x - scroll_x, base.y);
+                                    largetux.stand_right->draw(base.x - scroll_x, base.y);
                                   else
-                                    largetux_stand_left->draw(base.x - scroll_x, base.y);
+                                    largetux.stand_left->draw(base.x - scroll_x, base.y);
                                 }
                               else // walking
                                 {
                                   if (dir == RIGHT)
-                                    largetux_walk_right->draw(base.x - scroll_x, base.y);
+                                    largetux.walk_right->draw(base.x - scroll_x, base.y);
                                   else
-                                    largetux_walk_left->draw(base.x - scroll_x, base.y);
+                                    largetux.walk_left->draw(base.x - scroll_x, base.y);
                                 }
                             }
                           else
                             {
                               if (dir == RIGHT)
-                                largetux_jump_right->draw(base.x - scroll_x, base.y);
+                                largetux.jump_right->draw(base.x - scroll_x, base.y);
                               else
-                                largetux_jump_left->draw(base.x - scroll_x, base.y);
+                                largetux.jump_left->draw(base.x - scroll_x, base.y);
                             }
                         }
                       else
                         {
                           if (dir == RIGHT)
-                            largetux_skid_right->draw(base.x - scroll_x - 8, base.y);
+                            largetux.skid_right->draw(base.x - scroll_x - 8, base.y);
                           else
-                            largetux_skid_left->draw(base.x - scroll_x - 8, base.y);
+                            largetux.skid_left->draw(base.x - scroll_x - 8, base.y);
                         }
                     }
                   else
                     {
                       if (dir == RIGHT)
-                        largetux_duck_right->draw(base.x - scroll_x, base.y);
+                        largetux.duck_right->draw(base.x - scroll_x, base.y);
                       else
-                        largetux_duck_left->draw(base.x - scroll_x, base.y);
+                        largetux.duck_left->draw(base.x - scroll_x, base.y);
                     }
                 }
               else
@@ -670,9 +645,9 @@ Player::draw()
               if (holding_something && !duck && physic.get_velocity_y() == 0)
                 {
                   if (dir == RIGHT)
-                    largetux_grab_right->draw(base.x - scroll_x, base.y);
+                    largetux.grab_right->draw(base.x - scroll_x, base.y);
                   else
-                    largetux_grab_left->draw(base.x - scroll_x, base.y);
+                    largetux.grab_left->draw(base.x - scroll_x, base.y);
                 }
 
               if (invincible_timer.started())
index db7a0de..07e4fc9 100644 (file)
@@ -80,33 +80,26 @@ extern Sprite* smalltux_gameover;
 extern Sprite* smalltux_star;
 extern Sprite* largetux_star;
 
-extern Sprite* smalltux_stand_left;
-extern Sprite* smalltux_stand_right;
-extern Sprite* smalltux_walk_right;
-extern Sprite* smalltux_walk_left;
-extern Sprite* smalltux_jump_left;
-extern Sprite* smalltux_jump_right;
-extern Sprite* smalltux_kick_left;
-extern Sprite* smalltux_kick_right;
-extern Sprite* smalltux_skid_left;
-extern Sprite* smalltux_skid_right;
-extern Sprite* smalltux_grab_left;
-extern Sprite* smalltux_grab_right;
-
-extern Sprite* largetux_stand_left;
-extern Sprite* largetux_stand_right;
-extern Sprite* largetux_walk_right;
-extern Sprite* largetux_walk_left;
-extern Sprite* largetux_jump_right;
-extern Sprite* largetux_jump_left;
-extern Sprite* largetux_kick_left;
-extern Sprite* largetux_kick_right;
-extern Sprite* largetux_skid_right;
-extern Sprite* largetux_skid_left;
-extern Sprite* largetux_grab_left;
-extern Sprite* largetux_grab_right;
-extern Sprite* largetux_duck_right;
-extern Sprite* largetux_duck_left;
+struct PlayerSprite
+{
+  Sprite* stand_left;
+  Sprite* stand_right;
+  Sprite* walk_right;
+  Sprite* walk_left;
+  Sprite* jump_right;
+  Sprite* jump_left;
+  Sprite* kick_left;
+  Sprite* kick_right;
+  Sprite* skid_right;
+  Sprite* skid_left;
+  Sprite* grab_left;
+  Sprite* grab_right;
+  Sprite* duck_right;
+  Sprite* duck_left;
+};
+
+extern PlayerSprite smalltux;
+extern PlayerSprite largetux;
 
 extern Surface* firetux_right[3];
 extern Surface* firetux_left[3];
index e9691e7..103568c 100644 (file)
@@ -55,33 +55,33 @@ void loadshared()
   largetux_star = sprite_manager->load("largetux-star");
   smalltux_gameover = sprite_manager->load("smalltux-gameover");
 
-  smalltux_stand_left  = sprite_manager->load("smalltux-stand-left");
-  smalltux_stand_right = sprite_manager->load("smalltux-stand-right");
-  smalltux_walk_left   = sprite_manager->load("smalltux-walk-left");
-  smalltux_walk_right  = sprite_manager->load("smalltux-walk-right");
-  smalltux_jump_left   = sprite_manager->load("smalltux-jump-left");
-  smalltux_jump_right  = sprite_manager->load("smalltux-jump-right");
-  smalltux_kick_left   = sprite_manager->load("smalltux-kick-left");
-  smalltux_kick_right  = sprite_manager->load("smalltux-kick-right");
-  smalltux_skid_left   = sprite_manager->load("smalltux-skid-left");
-  smalltux_skid_right  = sprite_manager->load("smalltux-skid-right");
-  smalltux_grab_left   = sprite_manager->load("smalltux-grab-left");
-  smalltux_grab_right  = sprite_manager->load("smalltux-grab-right");
-
-  largetux_stand_left  = sprite_manager->load("largetux-stand-left");
-  largetux_stand_right = sprite_manager->load("largetux-stand-right");
-  largetux_walk_left   = sprite_manager->load("largetux-walk-left");
-  largetux_walk_right  = sprite_manager->load("largetux-walk-right");
-  largetux_jump_left   = sprite_manager->load("largetux-jump-left");
-  largetux_jump_right  = sprite_manager->load("largetux-jump-right");
-  largetux_kick_left   = sprite_manager->load("largetux-kick-left");
-  largetux_kick_right  = sprite_manager->load("largetux-kick-right");
-  largetux_skid_right  = sprite_manager->load("largetux-skid-right");
-  largetux_skid_left   = sprite_manager->load("largetux-skid-left");
-  largetux_grab_left   = sprite_manager->load("largetux-grab-left");
-  largetux_grab_right  = sprite_manager->load("largetux-grab-right");
-  largetux_duck_left   = sprite_manager->load("largetux-duck-left");
-  largetux_duck_right  = sprite_manager->load("largetux-duck-right");
+  smalltux.stand_left  = sprite_manager->load("smalltux-stand-left");
+  smalltux.stand_right = sprite_manager->load("smalltux-stand-right");
+  smalltux.walk_left   = sprite_manager->load("smalltux-walk-left");
+  smalltux.walk_right  = sprite_manager->load("smalltux-walk-right");
+  smalltux.jump_left   = sprite_manager->load("smalltux-jump-left");
+  smalltux.jump_right  = sprite_manager->load("smalltux-jump-right");
+  smalltux.kick_left   = sprite_manager->load("smalltux-kick-left");
+  smalltux.kick_right  = sprite_manager->load("smalltux-kick-right");
+  smalltux.skid_left   = sprite_manager->load("smalltux-skid-left");
+  smalltux.skid_right  = sprite_manager->load("smalltux-skid-right");
+  smalltux.grab_left   = sprite_manager->load("smalltux-grab-left");
+  smalltux.grab_right  = sprite_manager->load("smalltux-grab-right");
+
+  largetux.stand_left  = sprite_manager->load("largetux-stand-left");
+  largetux.stand_right = sprite_manager->load("largetux-stand-right");
+  largetux.walk_left   = sprite_manager->load("largetux-walk-left");
+  largetux.walk_right  = sprite_manager->load("largetux-walk-right");
+  largetux.jump_left   = sprite_manager->load("largetux-jump-left");
+  largetux.jump_right  = sprite_manager->load("largetux-jump-right");
+  largetux.kick_left   = sprite_manager->load("largetux-kick-left");
+  largetux.kick_right  = sprite_manager->load("largetux-kick-right");
+  largetux.skid_right  = sprite_manager->load("largetux-skid-right");
+  largetux.skid_left   = sprite_manager->load("largetux-skid-left");
+  largetux.grab_left   = sprite_manager->load("largetux-grab-left");
+  largetux.grab_right  = sprite_manager->load("largetux-grab-right");
+  largetux.duck_left   = sprite_manager->load("largetux-duck-left");
+  largetux.duck_right  = sprite_manager->load("largetux-duck-right");
 
   duckfiretux_right = new Surface(datadir +
                "/images/shared/duckfiretux-right.png",