(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"))
--- /dev/null
+(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")
+ )
+)
--- /dev/null
+(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")
+ )
+)
--- /dev/null
+// $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")
--- /dev/null
+// $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
#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)
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;
}
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();
}
{
//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;
}
}
}
--- /dev/null
+// $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")
--- /dev/null
+// $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