qmax patch to fix bug #0000389 - colors in infoblocks
[supertux.git] / src / badguy / stumpy.cpp
index 342879f..73dfc6b 100644 (file)
@@ -1,4 +1,4 @@
-//  $Id: stumpy.cpp 3980 2006-07-10 19:55:56Z sommer $
+//  $Id$
 //
 //  SuperTux
 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
@@ -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<Player*>(&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")
-