Powerup: Iceflower improvements
[supertux.git] / src / badguy / zeekling.cpp
index 8fff3ea..0ca8a56 100644 (file)
@@ -69,6 +69,11 @@ Zeekling::collision_squished(GameObject& object)
 
 void
 Zeekling::onBumpHorizontal() {
+  if (frozen)
+  {
+    physic.set_velocity_x(0);
+    return;
+  }
   if (state == FLYING) {
     dir = (dir == LEFT ? RIGHT : LEFT);
     sprite->set_action(dir == LEFT ? "left" : "right");
@@ -92,6 +97,12 @@ Zeekling::onBumpHorizontal() {
 
 void
 Zeekling::onBumpVertical() {
+  if (frozen)
+  {
+    physic.set_velocity_y(0);
+    physic.set_velocity_x(0);
+    return;
+  }
   if (state == FLYING) {
     physic.set_velocity_y(0);
   } else
@@ -127,6 +138,8 @@ Zeekling::collision_solid(const CollisionHit& hit)
  */
 bool
 Zeekling::should_we_dive() {
+  if (frozen)
+    return false;
 
   const MovingObject* player = this->get_nearest_player();
   if (player && last_player && (player == last_player)) {
@@ -200,4 +213,26 @@ Zeekling::active_update(float elapsed_time) {
   }
 }
 
+void
+Zeekling::freeze()
+{
+  BadGuy::freeze();
+  physic.enable_gravity(true);
+}
+
+void
+Zeekling::unfreeze()
+{
+  BadGuy::unfreeze();
+  physic.enable_gravity(false);
+  state = FLYING;
+  initialize();
+}
+
+bool
+Zeekling::is_freezable() const
+{
+  return true;
+}
+
 /* EOF */