Changed player stuff to use action. Bad guys should also be changed.
authorRicardo Cruz <rick2@aeiou.pt>
Thu, 12 Aug 2004 22:05:24 +0000 (22:05 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Thu, 12 Aug 2004 22:05:24 +0000 (22:05 +0000)
It was really time consuming to change all the entries from supertux.strf. There might be problems, especially with the arm. Anyway, since arm, body, head... will be all changed, this will be then fixed.

SVN-Revision: 1759

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

index a7c1447..ddc0e08 100644 (file)
@@ -930,7 +930,7 @@ le_level->get_sector("main")->solids->draw(context);
 
   /* Draw the player: */
   /* for now, the position is fixed at (100, 240) */
-  largetux.walk_right->draw(context, Vector(100 - pos_x, 240 - pos_y), LAYER_OBJECTS-1);
+//  largetux.walk_right->draw(context, Vector(100 - pos_x, 240 - pos_y), LAYER_OBJECTS-1);
 }
 
 void LevelEditor::change_object_properties(GameObject *pobj)
index c3170b3..f4af22a 100644 (file)
@@ -53,10 +53,12 @@ Sprite* smalltux_gameover;
 Sprite* smalltux_star;
 Sprite* largetux_star;
 
-PlayerSprite smalltux;
-PlayerSprite largetux;
-PlayerSprite icetux;
-PlayerSprite firetux;
+Sprite* small_tux;
+Sprite* big_tux;
+Sprite* ice_tux;
+Sprite* fire_tux;
+
+Sprite* tux_arm;
 
 PlayerKeymap keymap;
 
@@ -685,21 +687,21 @@ Player::grabdistros()
 void
 Player::draw(DrawingContext& context)
 {
-  PlayerSprite* sprite;
+  Sprite* sprite;
           
   if (size == SMALL)
-    sprite = &smalltux;
+    sprite = small_tux;
   else if (got_power == FIRE_POWER)
-    sprite = &firetux;
+    sprite = fire_tux;
   else if (got_power == ICE_POWER)
-    sprite = &icetux;
+    sprite = ice_tux;
   else
-    sprite = &largetux;
+    sprite = big_tux;
 
   int layer = LAYER_OBJECTS - 1;
   Vector pos = Vector(base.x, base.y);
 
-  if (!safe_timer.started() || (global_frame_counter % 2) == 0)
+  if ((!safe_timer.started() || growing_timer.started()) || (global_frame_counter % 2) == 0)
     {
       if (dying == DYING_SQUISHED)
         {
@@ -709,66 +711,86 @@ Player::draw(DrawingContext& context)
         {
           if(growing_timer.check())
             {
-              if (dir == RIGHT)
-                context.draw_surface(growingtux_right[(growing_timer.get_gone() * GROWING_FRAMES) / GROWING_TIME], pos, layer);
-              else 
-                context.draw_surface(growingtux_left[(growing_timer.get_gone() * GROWING_FRAMES) / GROWING_TIME], pos, layer);
+              if(size == SMALL)
+                {
+                if (dir == RIGHT)
+                  context.draw_surface(growingtux_right[GROWING_FRAMES-1 - 
+                          ((growing_timer.get_gone() *
+                          GROWING_FRAMES) / GROWING_TIME)], pos, layer);
+                else
+                  context.draw_surface(growingtux_left[GROWING_FRAMES-1 - 
+                          ((growing_timer.get_gone() *
+                          GROWING_FRAMES) / GROWING_TIME)], pos, layer);
+                }
+              else
+                {
+                if (dir == RIGHT)
+                  context.draw_surface(growingtux_right[(growing_timer.get_gone() *
+                          GROWING_FRAMES) / GROWING_TIME], pos, layer);
+                else
+                  context.draw_surface(growingtux_left[(growing_timer.get_gone() *
+                                       GROWING_FRAMES) / GROWING_TIME], pos, layer);
+                }
             }
           else if (duck && size != SMALL)
             {
               if (dir == RIGHT)
-                sprite->duck_right->draw(context, pos, layer);
+                sprite->set_action("duck-right");
               else 
-                sprite->duck_left->draw(context, pos, layer);
+                sprite->set_action("duck-left");
             }
           else if (skidding_timer.started())
             {
               if (dir == RIGHT)
-                sprite->skid_right->draw(context, pos, layer);
+                sprite->set_action("skid-right");
               else
-                sprite->skid_left->draw(context, pos, layer);
+                sprite->set_action("skid-left");
             }
           else if (kick_timer.started())
             {
               if (dir == RIGHT)
-                sprite->kick_right->draw(context, pos, layer);
+                sprite->set_action("kick-right");
               else
-                sprite->kick_left->draw(context, pos, layer);
+                sprite->set_action("kick-left");
             }
           else if (physic.get_velocity_y() != 0)
             {
               if (dir == RIGHT)
-                sprite->jump_right->draw(context, pos, layer);
+                sprite->set_action("jump-right");
               else
-                sprite->jump_left->draw(context, pos, layer);
+                sprite->set_action("jump-left");
             }
           else
             {
               if (fabsf(physic.get_velocity_x()) < 1.0f) // standing
                 {
                   if (dir == RIGHT)
-                    sprite->stand_right->draw(context, pos, layer);
+                    sprite->set_action("stand-right");
                   else
-                    sprite->stand_left->draw(context, pos, layer);
+                    sprite->set_action("stand-left");
                 }
               else // moving
                 {
                   if (dir == RIGHT)
-                    sprite->walk_right->draw(context, pos, layer);
+                    sprite->set_action("walk-right");
                   else
-                    sprite->walk_left->draw(context, pos, layer);
+                    sprite->set_action("walk-left");
                 }
             }
         }
-    }     
+    }
+
+  if(dying != DYING_SQUISHED && !growing_timer.check())
+    sprite->draw(context, pos, layer);
 
   // Draw arm overlay graphics when Tux is holding something
   if ((holding_something && physic.get_velocity_y() == 0) || shooting_timer.check() && !duck)
   {
     if (dir == RIGHT)
-      sprite->grab_right->draw(context, pos, LAYER_OBJECTS + 1);
+      tux_arm->set_action("walk-right");
     else
-      sprite->grab_left->draw(context, pos, LAYER_OBJECTS + 1);
+      tux_arm->set_action("walk-left");
+    tux_arm->draw(context, pos, LAYER_OBJECTS + 1);
   }
   
   // Draw blinking star overlay
@@ -924,15 +946,17 @@ Player::kill(HurtMode mode)
     {
       if (got_power != NONE_POWER)
         {
+          safe_timer.start(TUX_SAFE_TIME);
           got_power = NONE_POWER;
         }
       else
         {
+          growing_timer.start(GROWING_TIME);
+          safe_timer.start(TUX_SAFE_TIME + GROWING_TIME);
           size = SMALL;
           base.height = 32;
           duck = false;
         }
-      safe_timer.start(TUX_SAFE_TIME);
     }
   else
     {
index 6555527..719611b 100644 (file)
@@ -103,7 +103,7 @@ extern Sprite* largetux_star;
 extern Surface* growingtux_left[GROWING_FRAMES];
 extern Surface* growingtux_right[GROWING_FRAMES];
 
-struct PlayerSprite
+/*struct PlayerSprite
 {
   Sprite* stand_left;
   Sprite* stand_right;
@@ -119,12 +119,14 @@ struct PlayerSprite
   Sprite* grab_right;
   Sprite* duck_right;
   Sprite* duck_left;
-};
+};*/
+
+extern Sprite* small_tux;
+extern Sprite* big_tux;
+extern Sprite* fire_tux;
+extern Sprite* ice_tux;
 
-extern PlayerSprite smalltux;
-extern PlayerSprite largetux;
-extern PlayerSprite firetux;
-extern PlayerSprite icetux;
+extern Sprite* tux_arm;
 
 class Player : public MovingObject
 {
index 1664f20..9b69d67 100644 (file)
@@ -131,63 +131,12 @@ void loadshared()
       growingtux_right[i] = new Surface(img_name, true);
     }
 
-  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");
-
-  firetux.stand_left  = sprite_manager->load("firetux-stand-left");
-  firetux.stand_right = sprite_manager->load("firetux-stand-right");
-  firetux.walk_left   = sprite_manager->load("firetux-walk-left");
-  firetux.walk_right  = sprite_manager->load("firetux-walk-right");
-  firetux.jump_left   = sprite_manager->load("firetux-jump-left");
-  firetux.jump_right  = sprite_manager->load("firetux-jump-right");
-  firetux.kick_left   = sprite_manager->load("firetux-kick-left");
-  firetux.kick_right  = sprite_manager->load("firetux-kick-right");
-  firetux.skid_right  = sprite_manager->load("firetux-skid-right");
-  firetux.skid_left   = sprite_manager->load("firetux-skid-left");
-  firetux.grab_left   = sprite_manager->load("firetux-grab-left");
-  firetux.grab_right  = sprite_manager->load("firetux-grab-right");
-  firetux.duck_left   = sprite_manager->load("firetux-duck-left");
-  firetux.duck_right  = sprite_manager->load("firetux-duck-right");
-
-  icetux.stand_left  = sprite_manager->load("icetux-stand-left");
-  icetux.stand_right = sprite_manager->load("icetux-stand-right");
-  icetux.walk_left   = sprite_manager->load("icetux-walk-left");
-  icetux.walk_right  = sprite_manager->load("icetux-walk-right");
-  icetux.jump_left   = sprite_manager->load("icetux-jump-left");
-  icetux.jump_right  = sprite_manager->load("icetux-jump-right");
-  icetux.kick_left   = sprite_manager->load("icetux-kick-left");
-  icetux.kick_right  = sprite_manager->load("icetux-kick-right");
-  icetux.skid_right  = sprite_manager->load("icetux-skid-right");
-  icetux.skid_left   = sprite_manager->load("icetux-skid-left");
-  icetux.grab_left   = sprite_manager->load("icetux-grab-left");
-  icetux.grab_right  = sprite_manager->load("icetux-grab-right");
-  icetux.duck_left   = sprite_manager->load("icetux-duck-left");
-  icetux.duck_right  = sprite_manager->load("icetux-duck-right");
+  small_tux = sprite_manager->load("small-tux");
+  big_tux   = sprite_manager->load("big-tux");
+  ice_tux   = sprite_manager->load("ice-tux");
+  fire_tux  = sprite_manager->load("fire-tux");
+
+  tux_arm = sprite_manager->load("tux-arm");
 
   /* Water: */
   img_water = new Surface(datadir + "/images/shared/water.png", false);
@@ -198,6 +147,7 @@ void loadshared()
   img_waves[1] = new Surface(datadir + "/images/shared/waves-1.png",
                              true);
 
+
   img_waves[2] = new Surface(datadir + "/images/shared/waves-2.png",
                              true);