* Launcher can shoot two new types of snowballs.
authorWolfgang Becker <uafr@gmx.de>
Tue, 12 Feb 2008 19:36:28 +0000 (19:36 +0000)
committerWolfgang Becker <uafr@gmx.de>
Tue, 12 Feb 2008 19:36:28 +0000 (19:36 +0000)
SVN-Revision: 5323

27 files changed:
data/images/creatures/canon/canon.png [deleted file]
data/images/creatures/dispenser/canon.png [new file with mode: 0644]
data/images/creatures/dispenser/dispenser.sprite
data/images/creatures/snowball/collision-left.png [new file with mode: 0644]
data/images/creatures/snowball/cpt-left-0.png [new file with mode: 0644]
data/images/creatures/snowball/cpt-left-1.png [new file with mode: 0644]
data/images/creatures/snowball/cpt-left-2.png [new file with mode: 0644]
data/images/creatures/snowball/cpt-right-0.png [new file with mode: 0644]
data/images/creatures/snowball/cpt-right-1.png [new file with mode: 0644]
data/images/creatures/snowball/cpt-right-2.png [new file with mode: 0644]
data/images/creatures/snowball/cpt-snowball.sprite [new file with mode: 0644]
data/images/creatures/snowball/cpt-squished-left.png [new file with mode: 0644]
data/images/creatures/snowball/cpt-squished-right.png [new file with mode: 0644]
data/images/creatures/snowball/kamikaze-left.png [new file with mode: 0644]
data/images/creatures/snowball/kamikaze-snowball.sprite [new file with mode: 0644]
data/images/creatures/snowball/left-0.png
data/images/creatures/snowball/left-1.png
data/images/creatures/snowball/left-2.png
data/images/creatures/snowball/sport-left-0.png
data/images/creatures/snowball/sport-left-1.png
data/images/creatures/snowball/sport-left-2.png
data/images/creatures/snowball/squished-left.png
src/badguy/captainsnowball.cpp [new file with mode: 0644]
src/badguy/captainsnowball.hpp [new file with mode: 0644]
src/badguy/dispenser.cpp
src/badguy/kamikazesnowball.cpp [new file with mode: 0644]
src/badguy/kamikazesnowball.hpp [new file with mode: 0644]

diff --git a/data/images/creatures/canon/canon.png b/data/images/creatures/canon/canon.png
deleted file mode 100644 (file)
index cb658fd..0000000
Binary files a/data/images/creatures/canon/canon.png and /dev/null differ
diff --git a/data/images/creatures/dispenser/canon.png b/data/images/creatures/dispenser/canon.png
new file mode 100644 (file)
index 0000000..cb658fd
Binary files /dev/null and b/data/images/creatures/dispenser/canon.png differ
index cc2f3be..b7870ab 100644 (file)
@@ -5,6 +5,11 @@
   (images "dropper.png"))
  
  (action
+  (name "working")
+  (hitbox 3 5 32 60)
+  (images "canon.png"))
+ (action
   (name "working-left")
   (hitbox 5 12 55 40)
   (images "working.png"))
diff --git a/data/images/creatures/snowball/collision-left.png b/data/images/creatures/snowball/collision-left.png
new file mode 100644 (file)
index 0000000..87e3dde
Binary files /dev/null and b/data/images/creatures/snowball/collision-left.png differ
diff --git a/data/images/creatures/snowball/cpt-left-0.png b/data/images/creatures/snowball/cpt-left-0.png
new file mode 100644 (file)
index 0000000..9c43ae8
Binary files /dev/null and b/data/images/creatures/snowball/cpt-left-0.png differ
diff --git a/data/images/creatures/snowball/cpt-left-1.png b/data/images/creatures/snowball/cpt-left-1.png
new file mode 100644 (file)
index 0000000..c9f1296
Binary files /dev/null and b/data/images/creatures/snowball/cpt-left-1.png differ
diff --git a/data/images/creatures/snowball/cpt-left-2.png b/data/images/creatures/snowball/cpt-left-2.png
new file mode 100644 (file)
index 0000000..4d3d513
Binary files /dev/null and b/data/images/creatures/snowball/cpt-left-2.png differ
diff --git a/data/images/creatures/snowball/cpt-right-0.png b/data/images/creatures/snowball/cpt-right-0.png
new file mode 100644 (file)
index 0000000..81595c4
Binary files /dev/null and b/data/images/creatures/snowball/cpt-right-0.png differ
diff --git a/data/images/creatures/snowball/cpt-right-1.png b/data/images/creatures/snowball/cpt-right-1.png
new file mode 100644 (file)
index 0000000..7b15420
Binary files /dev/null and b/data/images/creatures/snowball/cpt-right-1.png differ
diff --git a/data/images/creatures/snowball/cpt-right-2.png b/data/images/creatures/snowball/cpt-right-2.png
new file mode 100644 (file)
index 0000000..00bf77c
Binary files /dev/null and b/data/images/creatures/snowball/cpt-right-2.png differ
diff --git a/data/images/creatures/snowball/cpt-snowball.sprite b/data/images/creatures/snowball/cpt-snowball.sprite
new file mode 100644 (file)
index 0000000..545151e
--- /dev/null
@@ -0,0 +1,26 @@
+(supertux-sprite
+  (action
+    (name "left")
+    (hitbox 2 4 31.8 31.8)
+    (images "cpt-left-0.png"
+            "cpt-left-1.png"
+            "cpt-left-2.png")
+  )
+  (action
+    (name "right")
+    (hitbox 8 4 31.8 31.8)
+    (images "cpt-right-0.png"
+            "cpt-right-1.png"
+            "cpt-right-2.png")
+  )
+  (action
+    (name "squished-left")
+    (hitbox 1 -19 31.8 31.8)
+    (images "cpt-squished-left.png")
+  )
+  (action
+    (name "squished-right")
+    (hitbox 1 -19 31.8 31.8)
+    (images "cpt-squished-right.png")
+  )
+)
diff --git a/data/images/creatures/snowball/cpt-squished-left.png b/data/images/creatures/snowball/cpt-squished-left.png
new file mode 100644 (file)
index 0000000..a1c3017
Binary files /dev/null and b/data/images/creatures/snowball/cpt-squished-left.png differ
diff --git a/data/images/creatures/snowball/cpt-squished-right.png b/data/images/creatures/snowball/cpt-squished-right.png
new file mode 100644 (file)
index 0000000..1e583bf
Binary files /dev/null and b/data/images/creatures/snowball/cpt-squished-right.png differ
diff --git a/data/images/creatures/snowball/kamikaze-left.png b/data/images/creatures/snowball/kamikaze-left.png
new file mode 100644 (file)
index 0000000..c5be838
Binary files /dev/null and b/data/images/creatures/snowball/kamikaze-left.png differ
diff --git a/data/images/creatures/snowball/kamikaze-snowball.sprite b/data/images/creatures/snowball/kamikaze-snowball.sprite
new file mode 100644 (file)
index 0000000..3aba29b
--- /dev/null
@@ -0,0 +1,30 @@
+(supertux-sprite
+  (action
+    (name "left")
+    (hitbox 2 4 31.8 23.8)
+    (images "kamikaze-left.png")
+  )
+  (action
+    (name "right")
+    (hitbox 13 4 31.8 23.8)
+    (mirror-action "left")
+  )
+  (action
+    (name "squished-left")
+    (hitbox 1 -19 31.8 31.8)
+    (images "squished-left.png")
+  )
+  (action
+    (name "squished-right")
+    (hitbox 1 -19 31.8 31.8)
+    (mirror-action "squished-left")
+  )
+  (action
+    (name "collision-left")
+    (images "collision-left.png")
+  )
+  (action
+    (name "collision-right")
+    (mirror-action "collision-left")
+  )
+)
index 5d6e718..fa8dde5 100644 (file)
Binary files a/data/images/creatures/snowball/left-0.png and b/data/images/creatures/snowball/left-0.png differ
index 1b53c24..2dcf8fb 100644 (file)
Binary files a/data/images/creatures/snowball/left-1.png and b/data/images/creatures/snowball/left-1.png differ
index ad04a77..b00204e 100644 (file)
Binary files a/data/images/creatures/snowball/left-2.png and b/data/images/creatures/snowball/left-2.png differ
index 82454b9..c5c6ede 100644 (file)
Binary files a/data/images/creatures/snowball/sport-left-0.png and b/data/images/creatures/snowball/sport-left-0.png differ
index 1abb5db..271d301 100644 (file)
Binary files a/data/images/creatures/snowball/sport-left-1.png and b/data/images/creatures/snowball/sport-left-1.png differ
index e853efe..463fa1c 100644 (file)
Binary files a/data/images/creatures/snowball/sport-left-2.png and b/data/images/creatures/snowball/sport-left-2.png differ
index df64fa9..4362c55 100644 (file)
Binary files a/data/images/creatures/snowball/squished-left.png and b/data/images/creatures/snowball/squished-left.png differ
diff --git a/src/badguy/captainsnowball.cpp b/src/badguy/captainsnowball.cpp
new file mode 100644 (file)
index 0000000..a6975da
--- /dev/null
@@ -0,0 +1,61 @@
+//  $Id$
+//
+//  SuperTux
+//  Copyright (C) 2008 Wolfgang Becker <uafr@gmx.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 "captainsnowball.hpp"
+
+namespace{
+  static const float WALK_SPEED = 50; 
+  static const float BOARDING_SPEED = 300;
+}
+
+
+CaptainSnowball::CaptainSnowball(const lisp::Lisp& reader)
+    : WalkingBadguy(reader, "images/creatures/snowball/cpt-snowball.sprite", "left", "right")
+{
+  walk_speed = WALK_SPEED; // peg leg
+  max_drop_height = -1;// eye patch
+}
+
+CaptainSnowball::CaptainSnowball(const Vector& pos, Direction d)
+    : WalkingBadguy(pos, d, "images/creatures/snowball/cpt-snowball.sprite", "left", "right")
+{
+  // Created during game eg. by dispencer. Board the enemy!
+  walk_speed = BOARDING_SPEED;
+  physic.set_velocity_y(-500);
+}
+
+void
+CaptainSnowball::collision_solid(const CollisionHit& hit)
+{
+  WalkingBadguy::collision_solid(hit);
+  walk_speed = WALK_SPEED;
+  physic.set_velocity_x(dir == LEFT ? -walk_speed : walk_speed);
+}
+
+bool
+CaptainSnowball::collision_squished(GameObject& object)
+{
+  sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
+  kill_squished(object);
+  return true;
+}
+
+IMPLEMENT_FACTORY(CaptainSnowball, "captainsnowball")
diff --git a/src/badguy/captainsnowball.hpp b/src/badguy/captainsnowball.hpp
new file mode 100644 (file)
index 0000000..b1043a0
--- /dev/null
@@ -0,0 +1,39 @@
+//  $Id$
+//
+//  SuperTux
+//  Copyright (C) 2008 Wolfgang Becker <uafr@gmx.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.
+
+#ifndef __CAPTAINSNOWBALL_H__
+#define __CAPTAINSNOWBALL_H__
+
+#include "walking_badguy.hpp"
+
+class CaptainSnowball : public WalkingBadguy
+{
+public:
+  CaptainSnowball(const lisp::Lisp& reader);
+  CaptainSnowball(const Vector& pos, Direction d);
+
+  virtual CaptainSnowball* clone() const { return new CaptainSnowball(*this); }
+  void collision_solid(const CollisionHit& hit);
+
+protected:
+  bool collision_squished(GameObject& object);
+
+};
+
+#endif
index c603946..73a931b 100644 (file)
@@ -28,6 +28,8 @@
 #include "badguy/poisonivy.hpp"
 #include "badguy/snail.hpp"
 #include "badguy/skullyhop.hpp"
+#include "badguy/captainsnowball.hpp"
+#include "badguy/kamikazesnowball.hpp"
 #include "random_generator.hpp"
 
 Dispenser::Dispenser(const lisp::Lisp& reader)
@@ -42,8 +44,11 @@ Dispenser::Dispenser(const lisp::Lisp& reader)
      if( start_dir == AUTO ){
       autotarget = true;
      }
+  } else if ( badguy == "kamikazesnowball" ||  badguy == "captainsnowball" ) {
+     sprite->set_action("working");
+  } else {
+    sprite->set_action("dropper");
   }
-  else {sprite->set_action("dropper");}
   bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
   countMe = false;
 }
@@ -64,6 +69,13 @@ Dispenser::write(lisp::Writer& writer)
 void
 Dispenser::activate()
 {
+   if( autotarget && !swivel ){ // auto canon sprite might be wrong
+      Player* player = this->get_nearest_player();
+      if( player ){
+        dir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
+        sprite->set_action(dir == LEFT ? "working-left" : "working-right");
+      }
+   }
    dispense_timer.start(cycle, true);
    launch_badguy();
 }
@@ -121,33 +133,44 @@ Dispenser::launch_badguy()
 {
   //FIXME: Does is_offscreen() work right here?
   if (!is_offscreen()) {
+    Direction launchdir = dir;
+    if( !autotarget && start_dir == AUTO ){
+      Player* player = this->get_nearest_player();
+      if( player ){
+        launchdir = (player->get_pos().x > get_pos().x) ? RIGHT : LEFT;
+      } 
+    } 
     if (badguy == "snowball")
-      Sector::current()->add_object(new SnowBall(Vector(get_pos().x, get_pos().y+32), dir));
+      Sector::current()->add_object(new SnowBall(Vector(get_pos().x, get_pos().y+32), launchdir));
     else if (badguy == "bouncingsnowball")
-      Sector::current()->add_object(new BouncingSnowball(Vector(get_pos().x, get_pos().y+32), dir));
+      Sector::current()->add_object(new BouncingSnowball(Vector(get_pos().x, get_pos().y+32), launchdir));
     else if (badguy == "mrbomb")
-      Sector::current()->add_object(new MrBomb(Vector(get_pos().x, get_pos().y+32), dir));
+      Sector::current()->add_object(new MrBomb(Vector(get_pos().x, get_pos().y+32), launchdir));
     else if (badguy == "mriceblock")
-      Sector::current()->add_object(new MrIceBlock(Vector(get_pos().x, get_pos().y+32), dir));
+      Sector::current()->add_object(new MrIceBlock(Vector(get_pos().x, get_pos().y+32), launchdir));
     else if (badguy == "snail")
-      Sector::current()->add_object(new Snail(Vector(get_pos().x, get_pos().y+32), dir));
-    else if (badguy == "mrrocket") {
-      Sector::current()->add_object(new MrRocket(Vector(get_pos().x+(dir == LEFT ? -32 : 32), get_pos().y), dir));}
+      Sector::current()->add_object(new Snail(Vector(get_pos().x, get_pos().y+32), launchdir));
+    else if (badguy == "mrrocket") 
+      Sector::current()->add_object(new MrRocket(Vector(get_pos().x+(launchdir == LEFT ? -32 : 32), get_pos().y), launchdir));
+    else if (badguy == "captainsnowball")
+      Sector::current()->add_object(new CaptainSnowball(Vector(get_pos().x+(launchdir == LEFT ? -32 : 32), get_pos().y), launchdir));
+    else if (badguy == "kamikazesnowball")
+      Sector::current()->add_object(new KamikazeSnowball(Vector(get_pos().x+(launchdir == LEFT ? -32 : 32), get_pos().y), launchdir));
     else if (badguy == "poisonivy")
-      Sector::current()->add_object(new PoisonIvy(Vector(get_pos().x, get_pos().y+32), dir));
+      Sector::current()->add_object(new PoisonIvy(Vector(get_pos().x, get_pos().y+32), launchdir));
     else if (badguy == "skullyhop")
-      Sector::current()->add_object(new SkullyHop(Vector(get_pos().x, get_pos().y+44), dir));
+      Sector::current()->add_object(new SkullyHop(Vector(get_pos().x, get_pos().y+44), launchdir));
     else if (badguy == "random")
     {
       switch (systemRandom.rand(7))
       {
-        case 0: Sector::current()->add_object(new SnowBall(Vector(get_pos().x, get_pos().y+32), dir)); break;
-        case 1: Sector::current()->add_object(new BouncingSnowball(Vector(get_pos().x, get_pos().y+32), dir)); break;
-        case 2: Sector::current()->add_object(new MrBomb(Vector(get_pos().x, get_pos().y+32), dir)); break;
-        case 3: Sector::current()->add_object(new MrIceBlock(Vector(get_pos().x, get_pos().y+32), dir)); break;
-        case 4: Sector::current()->add_object(new PoisonIvy(Vector(get_pos().x, get_pos().y+32), dir)); break;
-        case 5: Sector::current()->add_object(new Snail(Vector(get_pos().x, get_pos().y+32), dir)); break;
-        case 6: Sector::current()->add_object(new SkullyHop(Vector(get_pos().x, get_pos().y+44), dir)); break;
+        case 0: Sector::current()->add_object(new SnowBall(Vector(get_pos().x, get_pos().y+32), launchdir)); break;
+        case 1: Sector::current()->add_object(new BouncingSnowball(Vector(get_pos().x, get_pos().y+32), launchdir)); break;
+        case 2: Sector::current()->add_object(new MrBomb(Vector(get_pos().x, get_pos().y+32), launchdir)); break;
+        case 3: Sector::current()->add_object(new MrIceBlock(Vector(get_pos().x, get_pos().y+32), launchdir)); break;
+        case 4: Sector::current()->add_object(new PoisonIvy(Vector(get_pos().x, get_pos().y+32), launchdir)); break;
+        case 5: Sector::current()->add_object(new Snail(Vector(get_pos().x, get_pos().y+32), launchdir)); break;
+        case 6: Sector::current()->add_object(new SkullyHop(Vector(get_pos().x, get_pos().y+44), launchdir)); break;
       }
     }
   }
diff --git a/src/badguy/kamikazesnowball.cpp b/src/badguy/kamikazesnowball.cpp
new file mode 100644 (file)
index 0000000..ebfdc36
--- /dev/null
@@ -0,0 +1,94 @@
+//  $Id$
+//
+//  SuperTux
+//  Copyright (C) 2008 Wolfgang Becker <uafr@gmx.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 "kamikazesnowball.hpp"
+
+/* 
+ * Kamikaze Snowball will fly in one direction until he hits something.
+ * On impact he is destroyed, trying to kill what he hit or hit him. 
+ */
+namespace{
+  static const float SPEED = 200;
+  const std::string SPLAT_SOUND = "sounds/splat.wav";
+}
+
+KamikazeSnowball::KamikazeSnowball(const lisp::Lisp& reader)
+       : BadGuy(reader, "images/creatures/snowball/kamikaze-snowball.sprite")
+{
+  sound_manager->preload(SPLAT_SOUND);
+}
+
+KamikazeSnowball::KamikazeSnowball(const Vector& pos, Direction d)
+       : BadGuy(pos, d, "images/creatures/snowball/kamikaze-snowball.sprite")
+{
+  sound_manager->preload(SPLAT_SOUND);
+}
+
+void
+KamikazeSnowball::initialize()
+{
+  physic.set_velocity_x(dir == LEFT ? -SPEED : SPEED);
+  physic.enable_gravity(false);
+  sprite->set_action(dir == LEFT ? "left" : "right");
+}
+
+bool
+KamikazeSnowball::collision_squished(GameObject& object)
+{
+  sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
+  kill_squished(object);
+  return true;
+}
+
+void
+KamikazeSnowball::collision_solid(const CollisionHit& hit)
+{
+  if(hit.top || hit.bottom) {
+    physic.set_velocity_y(0);
+  } else if(hit.left || hit.right) {
+    kill_collision();
+  }
+}
+
+void
+KamikazeSnowball::kill_collision()
+{
+    sprite->set_action(dir == LEFT ? "collision-left" : "collision-right");
+    sound_manager->play(SPLAT_SOUND, get_pos());
+    physic.set_velocity_x(0);
+    physic.set_velocity_y(0);
+    physic.enable_gravity(true);
+    set_state(STATE_FALLING);
+}
+
+HitResponse
+KamikazeSnowball::collision_player(Player& player, const CollisionHit& hit)
+{
+  HitResponse response = BadGuy::collision_player(player, hit);
+  if(response == FORCE_MOVE){
+    kill_collision();
+    response = ABORT_MOVE;
+  }
+  return response;
+}
+
+
+IMPLEMENT_FACTORY(KamikazeSnowball, "kamikazesnowball")
diff --git a/src/badguy/kamikazesnowball.hpp b/src/badguy/kamikazesnowball.hpp
new file mode 100644 (file)
index 0000000..04854b8
--- /dev/null
@@ -0,0 +1,42 @@
+//  $Id$
+//
+//  SuperTux
+//  Copyright (C) 2008 Wolfgang Becker <uafr@gmx.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.
+
+#ifndef __KAMIKAZESNOWBALL_H__
+#define __KAMIKAZESNOWBALL_H__
+
+#include "badguy.hpp"
+
+class KamikazeSnowball : public BadGuy
+{
+public:
+  KamikazeSnowball(const lisp::Lisp& reader);
+  KamikazeSnowball(const Vector& pos, Direction d);
+
+  void initialize();
+  void collision_solid(const CollisionHit& hit);
+
+  virtual KamikazeSnowball* clone() const { return new KamikazeSnowball(*this); }
+
+protected:
+  bool collision_squished(GameObject& object);
+  HitResponse collision_player(Player& player, const CollisionHit& hit);
+  void kill_collision();
+};
+
+#endif