Made use of small tux.
authorRicardo Cruz <rick2@aeiou.pt>
Wed, 8 Sep 2004 11:23:29 +0000 (11:23 +0000)
committerRicardo Cruz <rick2@aeiou.pt>
Wed, 8 Sep 2004 11:23:29 +0000 (11:23 +0000)
Support for null body parts.

SVN-Revision: 1871

src/player.cpp
src/resources.cpp

index a2e168e..b7633fe 100644 (file)
@@ -88,29 +88,41 @@ void player_input_init(player_input_type* pplayer_input)
 void
 TuxBodyParts::set_action(std::string action)
 {
-  head->set_action(action);
-  body->set_action(action);
-  arms->set_action(action);
-  feet->set_action(action);
+  if(head != NULL)
+    head->set_action(action);
+  if(body != NULL)
+    body->set_action(action);
+  if(arms != NULL)
+    arms->set_action(action);
+  if(feet != NULL)
+    feet->set_action(action);
 }
 
 void
 TuxBodyParts::one_time_animation()
 {
-  head->start_animation(1);
-  body->start_animation(1);
-  arms->start_animation(1);
-  feet->start_animation(1);
+  if(head != NULL)
+    head->start_animation(1);
+  if(body != NULL)
+    body->start_animation(1);
+  if(arms != NULL)
+    arms->start_animation(1);
+  if(feet != NULL)
+    feet->start_animation(1);
 }
 
 void
 TuxBodyParts::draw(DrawingContext& context, const Vector& pos, int layer,
                   Uint32 drawing_effect)
 {
-  head->draw(context, pos, layer, drawing_effect);
-  body->draw(context, pos, layer, drawing_effect);
-  arms->draw(context, pos, layer, drawing_effect);
-  feet->draw(context, pos, layer, drawing_effect);
+  if(head != NULL)
+    head->draw(context, pos, layer, drawing_effect);
+  if(body != NULL)
+    body->draw(context, pos, layer, drawing_effect);
+  if(arms != NULL)
+    arms->draw(context, pos, layer, drawing_effect);
+  if(feet != NULL)
+    feet->draw(context, pos, layer, drawing_effect);
 }
 
 Player::Player()
@@ -759,8 +771,11 @@ Player::draw(DrawingContext& context)
 
   if(idle_timer.get_left() < 0)
     {
-    tux_body->head->set_action("idle");
-    tux_body->head->start_animation(1);
+    if(size == BIG)
+      {
+      tux_body->head->set_action("idle");
+      tux_body->head->start_animation(1);
+      }
 
     idle_timer.start(IDLE_TIME);
     }
index 03c9aa2..3913a05 100644 (file)
@@ -133,10 +133,10 @@ void loadshared()
     }
 
   small_tux = new TuxBodyParts();
-  small_tux->head = sprite_manager->load("big-tux-head");
-  small_tux->body = sprite_manager->load("big-tux-body");
-  small_tux->arms = sprite_manager->load("big-tux-arms");
-  small_tux->feet = sprite_manager->load("big-tux-feet");
+  small_tux->head = NULL;
+  small_tux->body = sprite_manager->load("small-tux-body");
+  small_tux->arms = sprite_manager->load("small-tux-arms");
+  small_tux->feet = NULL;
 
   big_tux = new TuxBodyParts();
   big_tux->head = sprite_manager->load("big-tux-head");