}
void
-Totem::activate()
+Totem::initialize()
{
if (!carried_by) {
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
if (on_ground() && might_fall())
{
dir = (dir == LEFT ? RIGHT : LEFT);
- activate();
+ initialize();
}
Sector* s = Sector::current();
}
bool
-Totem::collision_squished(Player& player)
+Totem::collision_squished(GameObject& object)
{
if (carrying) carrying->jump_off();
if (carried_by) {
- player.bounce(*this);
+ Player* player = dynamic_cast<Player*>(&object);
+ if (player) player->bounce(*this);
jump_off();
}
sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
- kill_squished(player);
+ kill_squished(object);
return true;
}
// If we are hit from the direction we are facing: turn around
if (hit.left && (dir == LEFT)) {
dir = RIGHT;
- activate();
+ initialize();
}
if (hit.right && (dir == RIGHT)) {
dir = LEFT;
- activate();
+ initialize();
}
}
// If we are hit from the direction we are facing: turn around
if(hit.left && (dir == LEFT)) {
dir = RIGHT;
- activate();
+ initialize();
}
if(hit.right && (dir == RIGHT)) {
dir = LEFT;
- activate();
+ initialize();
}
return CONTINUE;
target->carrying = this;
this->carried_by = target;
- this->activate();
+ this->initialize();
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
sound_manager->play( LAND_ON_TOTEM_SOUND , get_pos());
this->carried_by = 0;
- this->activate();
+ this->initialize();
bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());