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()
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);
}
}
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");