fixed a bug, added some debug messages
[supertux.git] / src / badguy / dispenser.cpp
index 2ff06b8..33bd1c9 100644 (file)
@@ -6,6 +6,7 @@
 #include "badguy/mrbomb.h"
 #include "badguy/mriceblock.h"
 #include "badguy/mrrocket.h"
+#include "badguy/poisonivy.h"
 
 Dispenser::Dispenser(const lisp::Lisp& reader)
 {
@@ -15,7 +16,10 @@ Dispenser::Dispenser(const lisp::Lisp& reader)
   reader.get("badguy", badguy);
   bbox.set_size(32, 32);
   sprite = sprite_manager->create("dispenser");
-  sprite->set_action("working");
+  if (badguy == "mrrocket") {
+     sprite->set_action(dir == LEFT ? "working-left" : "working-right");
+  }
+  else {sprite->set_action("dropper");}
 }
 
 void
@@ -42,7 +46,7 @@ bool
 Dispenser::collision_squished(Player& player)
 {
   //TODO: Should it act like a normal tile when killed?
-  sprite->set_action("broken");
+  sprite->set_action(dir == LEFT ? "broken-left" : "broken-right");
   dispense_timer.start(0);
   player.bounce(*this);
   kill_squished(player);
@@ -58,7 +62,8 @@ Dispenser::active_action(float )
 }
 
 //TODO: Add launching velocity to certain badguys
-//      Add randomizer (themed to match tileset)
+//      Add themed randomizer
+//      Fix initial direction (everyone but MrRocket walks the wrong direction)
 void
 Dispenser::launch_badguy()
 {
@@ -72,10 +77,22 @@ Dispenser::launch_badguy()
       Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir));
     else if (badguy == "mriceblock")
       Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir));
-    else if (badguy == "mrrocket")
-      Sector::current()->add_object(new MrRocket(get_pos().x, get_pos().y+32, dir));
+    else if (badguy == "mrrocket") {
+      int offset = (dir == LEFT ? -32 : 32);
+      Sector::current()->add_object(new MrRocket(get_pos().x+offset, get_pos().y, dir));}
+    else if (badguy == "poisonivy")
+      Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir));
     else if (badguy == "random")
-    {}
+    {
+      switch (rand()%5)
+      {
+        case 0: Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir)); break;
+        case 1: Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir)); break;
+        case 2: Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir)); break;
+        case 3: Sector::current()->add_object(new MrIceBlock(get_pos().x, get_pos().y+32, dir)); break;
+        case 4: Sector::current()->add_object(new PoisonIvy(get_pos().x, get_pos().y+32, dir)); break;
+      }
+    }
   }
 }