-// $Id: stumpy.cpp 3980 2006-07-10 19:55:56Z sommer $
+// $Id$
//
// SuperTux
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
: WalkingBadguy(reader, "images/creatures/mr_tree/stumpy.sprite","left","right"), mystate(STATE_NORMAL)
{
walk_speed = WALKSPEED;
- max_drop_height = 0;
- sound_manager->preload("sounds/mr_tree.ogg");
+ max_drop_height = 16;
sound_manager->preload("sounds/mr_treehit.ogg");
}
: WalkingBadguy(pos, d, "images/creatures/mr_tree/stumpy.sprite","left","right"), mystate(STATE_INVINCIBLE)
{
walk_speed = WALKSPEED;
- max_drop_height = 0;
+ max_drop_height = 16;
sound_manager->preload("sounds/mr_treehit.ogg");
invincible_timer.start(INVINCIBLE_TIME);
}
}
void
-Stumpy::activate()
+Stumpy::initialize()
{
switch (mystate) {
case STATE_INVINCIBLE:
physic.set_velocity_x(0);
break;
case STATE_NORMAL:
- WalkingBadguy::activate();
+ WalkingBadguy::initialize();
break;
}
}
switch (mystate) {
case STATE_INVINCIBLE:
if (invincible_timer.check()) {
- mystate = STATE_NORMAL;
- WalkingBadguy::activate();
+ mystate = STATE_NORMAL;
+ WalkingBadguy::initialize();
}
BadGuy::active_update(elapsed_time);
break;
}
bool
-Stumpy::collision_squished(Player& player)
+Stumpy::collision_squished(GameObject& object)
{
// if we're still invincible, we ignore the hit
if (mystate == STATE_INVINCIBLE) {
sound_manager->play("sounds/mr_treehit.ogg", get_pos());
- player.bounce(*this);
+ Player* player = dynamic_cast<Player*>(&object);
+ if (player) player->bounce(*this);
return true;
}
if (mystate == STATE_NORMAL) {
sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
- kill_squished(player);
+ kill_squished(object);
// spawn some particles
// TODO: provide convenience function in MovingSprite or MovingObject?
for (int i = 0; i < 25; i++) {
switch (mystate) {
case STATE_INVINCIBLE:
if(hit.top || hit.bottom) {
- physic.set_velocity_y(0);
+ physic.set_velocity_y(0);
}
if(hit.left || hit.right) {
- physic.set_velocity_x(0);
+ physic.set_velocity_x(0);
}
return CONTINUE;
break;