Set SSpiky max drop height to the same value as Spiky, making their behavior consistent
[supertux.git] / src / badguy / yeti_stalactite.cpp
index 12a925e..4e869d9 100644 (file)
 
 #include "badguy/yeti_stalactite.hpp"
 
+#include "sprite/sprite.hpp"
 #include "supertux/object_factory.hpp"
 
-static const float SHAKE_TIME = .8f;
+static const float YT_SHAKE_TIME = .8f;
 
 YetiStalactite::YetiStalactite(const Reader& lisp)
   : Stalactite(lisp)
@@ -32,8 +33,11 @@ YetiStalactite::~YetiStalactite()
 void
 YetiStalactite::start_shaking()
 {
-  timer.start(SHAKE_TIME);
+  timer.start(YT_SHAKE_TIME);
   state = STALACTITE_SHAKING;
+  if(((int)get_pos().x / 32) % 2 == 0) {
+    physic.set_velocity_y(100);
+  }
 }
 
 bool
@@ -51,4 +55,21 @@ YetiStalactite::active_update(float elapsed_time)
   Stalactite::active_update(elapsed_time);
 }
 
+void
+YetiStalactite::update(float elapsed_time)
+{
+  // Respawn instead of removing once squished
+  if(get_state() == STATE_SQUISHED && check_state_timer()) {
+    set_state(STATE_ACTIVE);
+    state = STALACTITE_HANGING;
+    // Hopefully we shouldn't come into contact with anything...
+    sprite->set_action("normal");
+    set_pos(start_position);
+    set_colgroup_active(COLGROUP_TOUCHABLE);
+  }
+
+  // Call back to badguy to do normal stuff
+  BadGuy::update(elapsed_time);
+}
+
 /* EOF */