X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fbadguy%2Fstumpy.cpp;h=73dfc6b192591253172fcf337357a736948e0598;hb=198f758764fff064a47630b5d0f1e3d6aabe95a8;hp=342879fd8bd7432ef912f91d0aa01206b8f5f4dd;hpb=ba9bdc73e3b80adcb6d9228cec62d1b7c44f8653;p=supertux.git diff --git a/src/badguy/stumpy.cpp b/src/badguy/stumpy.cpp index 342879fd8..73dfc6b19 100644 --- a/src/badguy/stumpy.cpp +++ b/src/badguy/stumpy.cpp @@ -1,4 +1,4 @@ -// $Id: stumpy.cpp 3980 2006-07-10 19:55:56Z sommer $ +// $Id$ // // SuperTux // Copyright (C) 2006 Matthias Braun @@ -31,8 +31,7 @@ Stumpy::Stumpy(const lisp::Lisp& reader) : 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"); } @@ -40,7 +39,7 @@ Stumpy::Stumpy(const Vector& pos, Direction d) : 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); } @@ -55,7 +54,7 @@ Stumpy::write(lisp::Writer& writer) } void -Stumpy::activate() +Stumpy::initialize() { switch (mystate) { case STATE_INVINCIBLE: @@ -64,7 +63,7 @@ Stumpy::activate() physic.set_velocity_x(0); break; case STATE_NORMAL: - WalkingBadguy::activate(); + WalkingBadguy::initialize(); break; } } @@ -75,8 +74,8 @@ Stumpy::active_update(float elapsed_time) 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; @@ -87,13 +86,14 @@ Stumpy::active_update(float elapsed_time) } 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(&object); + if (player) player->bounce(*this); return true; } @@ -101,7 +101,7 @@ Stumpy::collision_squished(Player& player) 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++) { @@ -149,10 +149,10 @@ Stumpy::collision_badguy(BadGuy& badguy, const CollisionHit& hit) 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; @@ -164,4 +164,3 @@ Stumpy::collision_badguy(BadGuy& badguy, const CollisionHit& hit) } IMPLEMENT_FACTORY(Stumpy, "stumpy") -