Stalactites break free when disturbed by fire and ice bullets
[supertux.git] / src / badguy / snowman.cpp
index 17783de..4a3cc2c 100644 (file)
@@ -38,20 +38,27 @@ Snowman::collision_squished(GameObject& object)
   // replace with Snowball
   Vector snowball_pos = get_pos();
   // Hard-coded values from sprites
-  snowball_pos.x += 2;
-  snowball_pos.y += 40;
+  snowball_pos.x += 5;
+  snowball_pos.y += 1;
 
+  // bounce
+  Player* player = dynamic_cast<Player*>(&object);
+  if (player)
+    player->bounce(*this);
+
+  /* Create death animation for the (now headless) snowman. */
+  set_action (dir == LEFT ? "headless-left" : "headless-right", /* loops = */ -1);
+  set_pos (get_pos () + Vector (-4.0, 19.0)); /* difference in the sprite offsets */
+  physic.set_velocity_y(0);
+  physic.set_acceleration_y(0);
+  physic.enable_gravity(true);
+  set_state (STATE_FALLING);
+
+  /* Create a new snowball where the snowman's head was */
+  /* TODO: Pass on our "dead_script" to the snowball. */
   SnowBall* snowball = new SnowBall(snowball_pos, dir);
-  remove_me();
   Sector::current()->add_object(snowball);
 
-  // bounce
-  Player* player = dynamic_cast<Player*>(&object);
-  if (player) player->bounce(*this);
-/*
-  sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
-  kill_squished(object);
-*/
   return true;
 }