- Implemented a scripted object that can be placed in a level and whose name is
[supertux.git] / src / badguy / dispenser.cpp
index 9bd2cc0..b72daae 100644 (file)
@@ -1,3 +1,23 @@
+//  $Id$
+// 
+//  SuperTux
+//  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+//  02111-1307, USA.
+
 #include <config.h>
 
 #include "dispenser.h"
@@ -16,7 +36,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
@@ -43,7 +66,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);
@@ -74,8 +97,8 @@ 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") {
+      Sector::current()->add_object(new MrRocket(get_pos().x+(dir == LEFT ? -32 : 32), 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")
@@ -86,8 +109,7 @@ Dispenser::launch_badguy()
         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 MrRocket(get_pos().x, get_pos().y+32, dir)); break;
-        case 5: Sector::current()->add_object(new PoisonIvy(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;
       }
     }
   }