static const float RECOVER_TIME = .5;
AngryStone::AngryStone(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/angrystone/angrystone.sprite"), state(IDLE)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/angrystone/angrystone.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
- state = IDLE;
}
void
static const float X_OFFSCREEN_DISTANCE = 1600;
static const float Y_OFFSCREEN_DISTANCE = 1200;
-BadGuy::BadGuy()
- : countMe(true), sprite(0), dir(LEFT), layer(LAYER_OBJECTS), state(STATE_INIT) {
- set_group(COLGROUP_DISABLED);
-}
-
-BadGuy::BadGuy(const BadGuy& other)
- : MovingObject(other), Serializable(other), countMe(other.countMe), physic(other.physic), activated(other.activated), start_position(other.start_position), dir(other.dir), layer(other.layer), state(other.state), state_timer(other.state_timer)
+BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name, int layer)
+ : MovingSprite(pos, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), state(STATE_INIT)
{
- sprite = new Sprite(*other.sprite);
+ start_position = bbox.p1;
}
-BadGuy::~BadGuy()
+BadGuy::BadGuy(const lisp::Lisp& reader, const std::string& sprite_name, int layer)
+ : MovingSprite(reader, sprite_name, layer, COLGROUP_DISABLED), countMe(true), dir(LEFT), state(STATE_INIT)
{
- delete sprite;
+ start_position = bbox.p1;
}
void
// moved them here to make it less typing when implementing new badguys
#include <math.h>
#include "timer.hpp"
-#include "moving_object.hpp"
-#include "sprite/sprite.hpp"
+#include "object/moving_sprite.hpp"
#include "physic.hpp"
#include "object/player.hpp"
#include "serializable.hpp"
#include "video/drawing_context.hpp"
#include "audio/sound_manager.hpp"
#include "audio/sound_source.hpp"
-#include "sprite/sprite_manager.hpp"
-class BadGuy : public MovingObject, public Serializable
+class BadGuy : public MovingSprite, public Serializable
{
public:
- BadGuy();
- BadGuy(const BadGuy& badguy);
- ~BadGuy();
+ BadGuy(const Vector& pos, const std::string& sprite_name, int layer = LAYER_OBJECTS);
+ BadGuy(const lisp::Lisp& reader, const std::string& sprite_name, int layer = LAYER_OBJECTS);
+ virtual BadGuy* clone() const = 0;
/** Called when the badguy is drawn. The default implementation simply draws
* the badguy sprite on screen
* during runtime. */
bool countMe;
- virtual BadGuy* clone() const = 0;
-
protected:
enum State {
STATE_INIT,
*/
Player* get_nearest_player();
- Sprite* sprite;
Physic physic;
/// is the enemy activated
Direction dir;
- /**
- * z-position at which to draw the sprite.
- * e.g. LAYER_OBJECTS, LAYER_OBJECTS - 1, LAYER_FLOATINGOBJECTS
- */
- int layer;
-
private:
void try_activate();
static const float EXPLOSIONTIME = 1;
Bomb::Bomb(const Vector& pos, Direction dir)
+ : BadGuy(pos, "images/creatures/mr_bomb/bomb.sprite")
{
- start_position = pos;
- bbox.set_pos(pos);
- sprite = sprite_manager->create("images/creatures/mr_bomb/bomb.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
state = STATE_TICKING;
timer.start(TICKINGTIME);
this->dir = dir;
static const float WALKSPEED = 80;
BouncingSnowball::BouncingSnowball(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/bouncing_snowball/bouncing_snowball.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/bouncing_snowball/bouncing_snowball.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = false;
}
-BouncingSnowball::BouncingSnowball(float pos_x, float pos_y, Direction d)
+BouncingSnowball::BouncingSnowball(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/bouncing_snowball/bouncing_snowball.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/bouncing_snowball/bouncing_snowball.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
}
{
public:
BouncingSnowball(const lisp::Lisp& reader);
- BouncingSnowball(float pos_x, float pos_y, Direction d);
+ BouncingSnowball(const Vector& pos, Direction d);
void activate();
void write(lisp::Writer& writer);
const float SPEED = 200;
}
-Dart::Dart(const lisp::Lisp& reader) : set_direction(false), parent(0), soundSource(0)
+Dart::Dart(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/dart/dart.sprite"), set_direction(false), parent(0), soundSource(0)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/dart/dart.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(false);
countMe = false;
}
-Dart::Dart(float pos_x, float pos_y, Direction d, const BadGuy* parent = 0) : set_direction(true), initial_direction(d), parent(parent), soundSource(0)
+Dart::Dart(const Vector& pos, Direction d, const BadGuy* parent = 0)
+ : BadGuy(pos, "images/creatures/dart/dart.sprite"), set_direction(false), parent(0), soundSource(0)
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/dart/dart.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(false);
countMe = false;
}
{
public:
Dart(const lisp::Lisp& reader);
- Dart(float pos_x, float pos_y, Direction d, const BadGuy* parent);
+ Dart(const Vector& pos, Direction d, const BadGuy* parent);
Dart(const Dart& dart);
~Dart();
const float MUZZLE_Y = 28; /**< [px] muzzle y-offset from top */
}
-DartTrap::DartTrap(const lisp::Lisp& reader) : set_direction(true), initial_direction(LEFT), initial_delay(0), fire_delay(2), ammo(-1), state(IDLE)
+DartTrap::DartTrap(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/darttrap/darttrap.sprite"), set_direction(true), initial_direction(LEFT), initial_delay(0), fire_delay(2), ammo(-1), state(IDLE)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
reader.get("initial-delay", initial_delay);
reader.get("fire-delay", fire_delay);
reader.get("ammo", ammo);
- sprite = sprite_manager->create("images/creatures/darttrap/darttrap.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
countMe = false;
}
py += MUZZLE_Y;
sound_manager->play("sounds/squish.wav", get_pos());
- Sector::current()->add_object(new Dart(px, py, dir, this));
+ Sector::current()->add_object(new Dart(Vector(px, py), dir, this));
state = IDLE;
sprite->set_action(dir == LEFT ? "idle-left" : "idle-right");
}
#include "random_generator.hpp"
Dispenser::Dispenser(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/dispenser/dispenser.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
reader.get("cycle", cycle);
reader.get("badguy", badguy);
- sprite = sprite_manager->create("images/creatures/dispenser/dispenser.sprite");
if (badguy == "mrrocket") {
sprite->set_action(dir == LEFT ? "working-left" : "working-right");
}
//FIXME: Does is_offscreen() work right here?
if (!is_offscreen()) {
if (badguy == "snowball")
- Sector::current()->add_object(new SnowBall(get_pos().x, get_pos().y+32, dir));
+ Sector::current()->add_object(new SnowBall(Vector(get_pos().x, get_pos().y+32), dir));
else if (badguy == "bouncingsnowball")
- Sector::current()->add_object(new BouncingSnowball(get_pos().x, get_pos().y+32, dir));
+ Sector::current()->add_object(new BouncingSnowball(Vector(get_pos().x, get_pos().y+32), dir));
else if (badguy == "mrbomb")
- Sector::current()->add_object(new MrBomb(get_pos().x, get_pos().y+32, dir));
+ Sector::current()->add_object(new MrBomb(Vector(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));
+ Sector::current()->add_object(new MrIceBlock(Vector(get_pos().x, get_pos().y+32), dir));
else if (badguy == "snail")
- Sector::current()->add_object(new Snail(get_pos().x, get_pos().y+32, dir));
+ 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(get_pos().x+(dir == LEFT ? -32 : 32), get_pos().y, dir));}
+ Sector::current()->add_object(new MrRocket(Vector(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));
+ Sector::current()->add_object(new PoisonIvy(Vector(get_pos().x, get_pos().y+32), dir));
else if (badguy == "skullyhop")
- Sector::current()->add_object(new SkullyHop(get_pos().x, get_pos().y+44, dir));
+ Sector::current()->add_object(new SkullyHop(Vector(get_pos().x, get_pos().y+44), dir));
else if (badguy == "random")
{
switch (systemRandom.rand(7))
{
- 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;
- case 5: Sector::current()->add_object(new Snail(get_pos().x, get_pos().y+32, dir)); break;
- case 6: Sector::current()->add_object(new SkullyHop(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), 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;
}
}
}
static const float FISH_WAIT_TIME = 1;
Fish::Fish(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/fish/fish.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/fish/fish.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(true);
}
-Fish::Fish(float pos_x, float pos_y)
+Fish::Fish(const Vector& pos)
+ : BadGuy(pos, "images/creatures/fish/fish.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/fish/fish.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(true);
}
{
public:
Fish(const lisp::Lisp& );
- Fish(float x, float y);
+ Fish(const Vector& pos);
void draw(DrawingContext& context);
#include "log.hpp"
Flame::Flame(const lisp::Lisp& reader)
- : angle(0), radius(100), speed(2), source(0)
+ : BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS), angle(0), radius(100), speed(2), source(0)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
reader.get("radius", radius);
reader.get("speed", speed);
bbox.set_pos(Vector(start_position.x + cos(angle) * radius,
start_position.y + sin(angle) * radius));
- sprite = sprite_manager->create("images/creatures/flame/flame.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
countMe = false;
- layer = LAYER_FLOATINGOBJECTS;
}
Flame::Flame(const Flame& other)
}
FlyingSnowBall::FlyingSnowBall(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/flying_snowball/flying_snowball.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/flying_snowball/flying_snowball.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(false);
}
-FlyingSnowBall::FlyingSnowBall(float pos_x, float pos_y)
+FlyingSnowBall::FlyingSnowBall(const Vector& pos)
+ : BadGuy(pos, "images/creatures/flying_snowball/flying_snowball.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/flying_snowball/flying_snowball.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(false);
}
{
public:
FlyingSnowBall(const lisp::Lisp& reader);
- FlyingSnowBall(float pos_x, float pos_y);
+ FlyingSnowBall(const Vector& pos);
void activate();
void write(lisp::Writer& writer);
}
Igel::Igel(const lisp::Lisp& reader)
- : state(STATE_NORMAL)
+ : BadGuy(reader, "images/creatures/igel/igel.sprite"), state(STATE_NORMAL)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/igel/igel.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = false;
}
-Igel::Igel(float pos_x, float pos_y, Direction d)
- : state(STATE_NORMAL)
+Igel::Igel(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/igel/igel.sprite"), state(STATE_NORMAL)
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/igel/igel.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
}
{
public:
Igel(const lisp::Lisp& reader);
- Igel(float pos_x, float pos_y, Direction d);
+ Igel(const Vector& pos, Direction d);
void activate();
void write(lisp::Writer& writer);
static const float JUMPY_LOW_TOLERANCE=2;
Jumpy::Jumpy(const lisp::Lisp& reader)
- : groundhit_pos_set(false)
+ : BadGuy(reader, "images/creatures/jumpy/jumpy.sprite"), groundhit_pos_set(false)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/jumpy/jumpy.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
}
void
static const float Y_OFFSCREEN_DISTANCE = 1200;
Kugelblitz::Kugelblitz(const lisp::Lisp& reader)
- : groundhit_pos_set(false)
+ : BadGuy(Vector(0,0), "images/creatures/kugelblitz/kugelblitz.sprite"), groundhit_pos_set(false)
{
reader.get("x", start_position.x);
- start_position.y = 0; //place above visible area
- sprite = sprite_manager->create("images/creatures/kugelblitz/kugelblitz.sprite");
sprite->set_action("falling");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(false);
}
static const float WALKSPEED = 80;
MrBomb::MrBomb(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/mr_bomb/mr_bomb.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/mr_bomb/mr_bomb.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = false;
}
-MrBomb::MrBomb(float pos_x, float pos_y, Direction d)
+MrBomb::MrBomb(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/mr_bomb/mr_bomb.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/mr_bomb/mr_bomb.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
}
{
public:
MrBomb(const lisp::Lisp& reader);
- MrBomb(float pos_x, float pos_y, Direction d);
+ MrBomb(const Vector& pos, Direction d);
void activate();
void active_update(float elapsed_time);
}
MrIceBlock::MrIceBlock(const lisp::Lisp& reader)
- : ice_state(ICESTATE_NORMAL), squishcount(0)
+ : BadGuy(reader, "images/creatures/mr_iceblock/mr_iceblock.sprite"), ice_state(ICESTATE_NORMAL), squishcount(0)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/mr_iceblock/mr_iceblock.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = false;
}
-MrIceBlock::MrIceBlock(float pos_x, float pos_y, Direction d)
- : ice_state(ICESTATE_NORMAL), squishcount(0)
+MrIceBlock::MrIceBlock(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/mr_iceblock/mr_iceblock.sprite"), ice_state(ICESTATE_NORMAL), squishcount(0)
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/mr_iceblock/mr_iceblock.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
}
{
public:
MrIceBlock(const lisp::Lisp& reader);
- MrIceBlock(float pos_x, float pos_y, Direction d);
+ MrIceBlock(const Vector& pos, Direction d);
void activate();
void write(lisp::Writer& writer);
static const float SPEED = 200;
MrRocket::MrRocket(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/mr_rocket/mr_rocket.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/mr_rocket/mr_rocket.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = false;
}
-MrRocket::MrRocket(float pos_x, float pos_y, Direction d)
+MrRocket::MrRocket(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/mr_rocket/mr_rocket.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/mr_rocket/mr_rocket.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
}
{
public:
MrRocket(const lisp::Lisp& reader);
- MrRocket(float pos_x, float pos_y, Direction d);
+ MrRocket(const Vector& pos, Direction d);
void activate();
void active_update(float elapsed_time);
MrTree::MrTree(const lisp::Lisp& reader)
- : mystate(STATE_BIG)
+ : BadGuy(reader, "images/creatures/mr_tree/mr_tree.sprite"), mystate(STATE_BIG)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/mr_tree/mr_tree.sprite");
sprite->set_action(dir == LEFT ? "large-left" : "large-right");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
}
void
Vector leaf1_pos = Vector(pos.x - POISONIVY_WIDTH - 1, pos.y - POISONIVY_Y_OFFSET);
Rect leaf1_bbox = Rect(leaf1_pos.x, leaf1_pos.y, leaf1_pos.x + POISONIVY_WIDTH, leaf1_pos.y + POISONIVY_HEIGHT);
if (Sector::current()->is_free_space(leaf1_bbox)) {
- PoisonIvy* leaf1 = new PoisonIvy(leaf1_bbox.p1.x, leaf1_bbox.p1.y, LEFT);
+ PoisonIvy* leaf1 = new PoisonIvy(leaf1_bbox.p1, LEFT);
Sector::current()->add_object(leaf1);
}
Vector leaf2_pos = Vector(pos.x + sprite->get_current_hitbox_width() + 1, pos.y - POISONIVY_Y_OFFSET);
Rect leaf2_bbox = Rect(leaf2_pos.x, leaf2_pos.y, leaf2_pos.x + POISONIVY_WIDTH, leaf2_pos.y + POISONIVY_HEIGHT);
if (Sector::current()->is_free_space(leaf2_bbox)) {
- PoisonIvy* leaf2 = new PoisonIvy(leaf2_bbox.p1.x, leaf2_bbox.p1.y, RIGHT);
+ PoisonIvy* leaf2 = new PoisonIvy(leaf2_bbox.p1, RIGHT);
Sector::current()->add_object(leaf2);
}
//TODO: Create sprite, limit max number of snowballs
Nolok_01::Nolok_01(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/nolok/nolok.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/nolok/nolok.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
countMe = false;
}
-Nolok_01::Nolok_01(float pos_x, float pos_y)
+Nolok_01::Nolok_01(const Vector& pos)
+ : BadGuy(pos, "images/creatures/nolok/nolok.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/nolok/nolok.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
countMe = false;
}
}
case SHOOTING:
{
- Sector::current()->add_object(new Snail(get_pos().x - 64, get_pos().y, LEFT));
- Sector::current()->add_object(new Snail(get_pos().x + 64, get_pos().y, RIGHT));
+ Sector::current()->add_object(new Snail(Vector(get_pos().x - 64, get_pos().y), LEFT));
+ Sector::current()->add_object(new Snail(Vector(get_pos().x + 64, get_pos().y), RIGHT));
physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED);
sprite->set_action(dir == LEFT ? "left" : "right");
action = WALKING;
{
public:
Nolok_01(const lisp::Lisp& reader);
- Nolok_01(float pos_x, float pos_y);
+ Nolok_01(const Vector& pos);
void activate();
void write(lisp::Writer& writer);
static const float WAKE_TIME = .5;
Plant::Plant(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/plant/plant.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/plant/plant.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
state = PLANT_SLEEPING;
}
static const float WALKSPEED = 80;
PoisonIvy::PoisonIvy(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/poison_ivy/poison_ivy.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/poison_ivy/poison_ivy.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = false;
}
-PoisonIvy::PoisonIvy(float pos_x, float pos_y, Direction d)
+PoisonIvy::PoisonIvy(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/poison_ivy/poison_ivy.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/poison_ivy/poison_ivy.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
}
{
public:
PoisonIvy(const lisp::Lisp& reader);
- PoisonIvy(float pos_x, float pos_y, Direction d);
+ PoisonIvy(const Vector& pos, Direction d);
void activate();
void write(lisp::Writer& writer);
static const float EXPLOSIONTIME = 1;
RocketExplosion::RocketExplosion(const Vector& pos, Direction dir)
+ : BadGuy(pos, "images/creatures/mr_rocket/explosion.sprite")
{
- start_position = pos;
- bbox.set_pos(pos);
- sprite = sprite_manager->create("images/creatures/mr_rocket/explosion.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
this->dir = dir;
countMe = false;
explode();
}
SkullyHop::SkullyHop(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/skullyhop/skullyhop.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/skullyhop/skullyhop.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
has_initial_direction = false;
}
-SkullyHop::SkullyHop(float pos_x, float pos_y, Direction d)
+SkullyHop::SkullyHop(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/skullyhop/skullyhop.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/skullyhop/skullyhop.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
has_initial_direction = true;
initial_direction = d;
}
{
public:
SkullyHop(const lisp::Lisp& reader);
- SkullyHop(float pos_x, float pos_y, Direction d);
+ SkullyHop(const Vector& pos, Direction d);
void activate();
void write(lisp::Writer& writer);
}
Snail::Snail(const lisp::Lisp& reader)
- : state(STATE_NORMAL), squishcount(0)
+ : BadGuy(reader, "images/creatures/snail/snail.sprite"), state(STATE_NORMAL), squishcount(0)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/snail/snail.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = false;
}
-Snail::Snail(float pos_x, float pos_y, Direction d)
- : state(STATE_NORMAL), squishcount(0)
+Snail::Snail(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/snail/snail.sprite"), state(STATE_NORMAL), squishcount(0)
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/snail/snail.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
}
{
public:
Snail(const lisp::Lisp& reader);
- Snail(float pos_x, float pos_y, Direction d);
+ Snail(const Vector& pos, Direction d);
void activate();
void write(lisp::Writer& writer);
static const float WALKSPEED = 80;
SnowBall::SnowBall(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/snowball/snowball.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- //This is for a hidden badguy :)
+ /*
fluffy = false;
reader.get("fluffy",fluffy);
- if (fluffy) sprite = sprite_manager->create("images/creatures/fluffy/fluffy.sprite");
- else sprite = sprite_manager->create("images/creatures/snowball/snowball.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
+ if (fluffy) {
+ delete sprite;
+ sprite = sprite_manager->create("images/creatures/fluffy/fluffy.sprite");
+ }
+ */
set_direction = false;
}
-SnowBall::SnowBall(float pos_x, float pos_y, Direction d)
+SnowBall::SnowBall(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/snowball/snowball.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/snowball/snowball.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
}
writer.write_float("x", start_position.x);
writer.write_float("y", start_position.y);
-
+ /*
if (fluffy) { // don't give us away at every snowball
writer.write_bool("fluffy", true);
}
-
+ */
writer.end_list("snowball");
}
{
public:
SnowBall(const lisp::Lisp& reader);
- SnowBall(float pos_x, float pos_y, Direction d);
+ SnowBall(const Vector& pos, Direction d);
void activate();
void write(lisp::Writer& writer);
bool collision_squished(Player& player);
bool set_direction;
Direction initial_direction;
- bool fluffy;
+ //bool fluffy;
};
#endif
static const float FLYSPEED = 100.0;
SpiderMite::SpiderMite(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/spidermite/spidermite.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/spidermite/spidermite.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(false);
}
-SpiderMite::SpiderMite(float pos_x, float pos_y)
+SpiderMite::SpiderMite(const Vector& pos)
+ : BadGuy(pos, "images/creatures/spidermite/spidermite.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/spidermite/spidermite.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
physic.enable_gravity(false);
}
{
public:
SpiderMite(const lisp::Lisp& reader);
- SpiderMite(float pos_x, float pos_y);
+ SpiderMite(const Vector& pos);
void activate();
void write(lisp::Writer& writer);
static const float WALKSPEED = 80;
Spiky::Spiky(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/spiky/spiky.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/spiky/spiky.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
}
void
static const float WAKE_TIME = .5;
SSpiky::SSpiky(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/spiky/sleepingspiky.sprite"), state(SSPIKY_SLEEPING)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/spiky/sleepingspiky.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
- state = SSPIKY_SLEEPING;
}
void
static const float SQUISH_TIME = 2;
Stalactite::Stalactite(const lisp::Lisp& lisp)
+ : BadGuy(lisp, "images/creatures/stalactite/stalactite.sprite"), state(STALACTITE_HANGING)
{
- lisp.get("x", start_position.x);
- lisp.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/stalactite/stalactite.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
- state = STALACTITE_HANGING;
countMe = false;
}
static const float JUMP_OFF_SPEED_Y = 500;
Totem::Totem(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/totem/totem.sprite")
{
carrying = 0;
carried_by = 0;
-
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/totem/totem.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
}
Totem::Totem(const Totem& other)
static const float VANISH_RANGE = 512; /**< at what distance to stop tracking and vanish */
WillOWisp::WillOWisp(const lisp::Lisp& reader)
- : mystate(STATE_IDLE), target_sector("main"), target_spawnpoint("main"), soundSource(0)
+ : BadGuy(reader, "images/creatures/willowisp/willowisp.sprite", LAYER_FLOATINGOBJECTS), mystate(STATE_IDLE), target_sector("main"), target_spawnpoint("main"), soundSource(0)
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
reader.get("sector", target_sector);
reader.get("spawnpoint", target_spawnpoint);
- sprite = sprite_manager->create("images/creatures/willowisp/willowisp.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
countMe = false;
- layer = LAYER_FLOATINGOBJECTS;
}
WillOWisp::WillOWisp(const WillOWisp& other)
}
Yeti::Yeti(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/yeti/yeti.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/yeti/yeti.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
hit_points = INITIAL_HITPOINTS;
reader.get("dead-script", dead_script);
countMe = false;
void
Yeti::summon_snowball()
{
- Sector::current()->add_object(new BouncingSnowball(get_pos().x+(dir == RIGHT ? 64 : -64), get_pos().y, dir));
+ Sector::current()->add_object(new BouncingSnowball(Vector(get_pos().x+(dir == RIGHT ? 64 : -64), get_pos().y), dir));
}
bool
#include "random_generator.hpp"
Zeekling::Zeekling(const lisp::Lisp& reader)
+ : BadGuy(reader, "images/creatures/zeekling/zeekling.sprite")
{
- reader.get("x", start_position.x);
- reader.get("y", start_position.y);
- sprite = sprite_manager->create("images/creatures/zeekling/zeekling.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = false;
state = FLYING;
}
-Zeekling::Zeekling(float pos_x, float pos_y, Direction d)
+Zeekling::Zeekling(const Vector& pos, Direction d)
+ : BadGuy(pos, "images/creatures/zeekling/zeekling.sprite")
{
- start_position.x = pos_x;
- start_position.y = pos_y;
- sprite = sprite_manager->create("images/creatures/zeekling/zeekling.sprite");
- bbox.set_size(sprite->get_current_hitbox_width(), sprite->get_current_hitbox_height());
set_direction = true;
initial_direction = d;
state = FLYING;
{
public:
Zeekling(const lisp::Lisp& reader);
- Zeekling(float pos_x, float pos_y, Direction d);
+ Zeekling(const Vector& pos, Direction d);
void activate();
void write(lisp::Writer& writer);