From: Christoph Sommer Date: Sat, 13 May 2006 17:12:21 +0000 (+0000) Subject: Badguys now inherit from MovingSprite X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=78e9b27b7059c9b9b16a7f871ab71f751ec75323;p=supertux.git Badguys now inherit from MovingSprite SVN-Revision: 3510 --- diff --git a/src/badguy/angrystone.cpp b/src/badguy/angrystone.cpp index a44e8363e..906112d5c 100644 --- a/src/badguy/angrystone.cpp +++ b/src/badguy/angrystone.cpp @@ -29,12 +29,8 @@ static const float ATTACK_TIME = 1; 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 diff --git a/src/badguy/badguy.cpp b/src/badguy/badguy.cpp index fa400f48f..51d5fd936 100644 --- a/src/badguy/badguy.cpp +++ b/src/badguy/badguy.cpp @@ -33,20 +33,16 @@ static const float SQUISH_TIME = 2; 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 diff --git a/src/badguy/badguy.hpp b/src/badguy/badguy.hpp index e9f68333b..eee973f52 100644 --- a/src/badguy/badguy.hpp +++ b/src/badguy/badguy.hpp @@ -23,8 +23,7 @@ // moved them here to make it less typing when implementing new badguys #include #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" @@ -38,14 +37,13 @@ #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 @@ -88,8 +86,6 @@ public: * during runtime. */ bool countMe; - virtual BadGuy* clone() const = 0; - protected: enum State { STATE_INIT, @@ -142,7 +138,6 @@ protected: */ Player* get_nearest_player(); - Sprite* sprite; Physic physic; /// is the enemy activated @@ -162,12 +157,6 @@ protected: 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(); diff --git a/src/badguy/bomb.cpp b/src/badguy/bomb.cpp index e06508669..17ae15565 100644 --- a/src/badguy/bomb.cpp +++ b/src/badguy/bomb.cpp @@ -25,11 +25,8 @@ static const float TICKINGTIME = 1; 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; diff --git a/src/badguy/bouncing_snowball.cpp b/src/badguy/bouncing_snowball.cpp index ba9536aef..76df35af0 100644 --- a/src/badguy/bouncing_snowball.cpp +++ b/src/badguy/bouncing_snowball.cpp @@ -25,20 +25,14 @@ static const float JUMPSPEED = 450; 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; } diff --git a/src/badguy/bouncing_snowball.hpp b/src/badguy/bouncing_snowball.hpp index a16ed2295..33a6c7663 100644 --- a/src/badguy/bouncing_snowball.hpp +++ b/src/badguy/bouncing_snowball.hpp @@ -26,7 +26,7 @@ class BouncingSnowball : public BadGuy { 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); diff --git a/src/badguy/dart.cpp b/src/badguy/dart.cpp index 8e508d9db..1c60a4448 100644 --- a/src/badguy/dart.cpp +++ b/src/badguy/dart.cpp @@ -26,22 +26,16 @@ namespace { 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; } diff --git a/src/badguy/dart.hpp b/src/badguy/dart.hpp index aaebdc26c..6a1c20d8a 100644 --- a/src/badguy/dart.hpp +++ b/src/badguy/dart.hpp @@ -30,7 +30,7 @@ class Dart : public BadGuy { 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(); diff --git a/src/badguy/darttrap.cpp b/src/badguy/darttrap.cpp index ad1ea9570..06381fe07 100644 --- a/src/badguy/darttrap.cpp +++ b/src/badguy/darttrap.cpp @@ -26,15 +26,12 @@ namespace { 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; } @@ -100,7 +97,7 @@ DartTrap::fire() 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"); } diff --git a/src/badguy/dispenser.cpp b/src/badguy/dispenser.cpp index 4ead78e1a..aaf50f150 100644 --- a/src/badguy/dispenser.cpp +++ b/src/badguy/dispenser.cpp @@ -31,12 +31,10 @@ #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"); } @@ -93,32 +91,32 @@ Dispenser::launch_badguy() //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; } } } diff --git a/src/badguy/fish.cpp b/src/badguy/fish.cpp index d70ad8a0d..ebd14c379 100644 --- a/src/badguy/fish.cpp +++ b/src/badguy/fish.cpp @@ -27,20 +27,14 @@ static const float FISH_JUMP_POWER = 600; 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); } diff --git a/src/badguy/fish.hpp b/src/badguy/fish.hpp index 812678396..6141ccb5f 100644 --- a/src/badguy/fish.hpp +++ b/src/badguy/fish.hpp @@ -26,7 +26,7 @@ class Fish : public BadGuy { public: Fish(const lisp::Lisp& ); - Fish(float x, float y); + Fish(const Vector& pos); void draw(DrawingContext& context); diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index 4bdafb6ff..330d8280b 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -23,18 +23,13 @@ #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) diff --git a/src/badguy/flyingsnowball.cpp b/src/badguy/flyingsnowball.cpp index e7bd28a80..a36a998c1 100644 --- a/src/badguy/flyingsnowball.cpp +++ b/src/badguy/flyingsnowball.cpp @@ -35,20 +35,14 @@ namespace { } 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); } diff --git a/src/badguy/flyingsnowball.hpp b/src/badguy/flyingsnowball.hpp index 3bac6399d..d9f8e9140 100644 --- a/src/badguy/flyingsnowball.hpp +++ b/src/badguy/flyingsnowball.hpp @@ -26,7 +26,7 @@ class FlyingSnowBall : public BadGuy { public: FlyingSnowBall(const lisp::Lisp& reader); - FlyingSnowBall(float pos_x, float pos_y); + FlyingSnowBall(const Vector& pos); void activate(); void write(lisp::Writer& writer); diff --git a/src/badguy/igel.cpp b/src/badguy/igel.cpp index 880096548..78d067a24 100644 --- a/src/badguy/igel.cpp +++ b/src/badguy/igel.cpp @@ -31,22 +31,14 @@ namespace { } 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; } diff --git a/src/badguy/igel.hpp b/src/badguy/igel.hpp index be0a7b39f..bdb7b75e0 100644 --- a/src/badguy/igel.hpp +++ b/src/badguy/igel.hpp @@ -30,7 +30,7 @@ class Igel : public BadGuy { 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); diff --git a/src/badguy/jumpy.cpp b/src/badguy/jumpy.cpp index 350b39d38..d6e71fea8 100644 --- a/src/badguy/jumpy.cpp +++ b/src/badguy/jumpy.cpp @@ -26,12 +26,8 @@ static const float JUMPY_MID_TOLERANCE=4; 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 diff --git a/src/badguy/kugelblitz.cpp b/src/badguy/kugelblitz.cpp index 10c4ef846..697678dd0 100644 --- a/src/badguy/kugelblitz.cpp +++ b/src/badguy/kugelblitz.cpp @@ -34,13 +34,10 @@ static const float X_OFFSCREEN_DISTANCE = 1600; 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); } diff --git a/src/badguy/mrbomb.cpp b/src/badguy/mrbomb.cpp index cb6954639..3d90f2fac 100644 --- a/src/badguy/mrbomb.cpp +++ b/src/badguy/mrbomb.cpp @@ -25,20 +25,14 @@ 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; } diff --git a/src/badguy/mrbomb.hpp b/src/badguy/mrbomb.hpp index 86c4fa610..c8a148744 100644 --- a/src/badguy/mrbomb.hpp +++ b/src/badguy/mrbomb.hpp @@ -26,7 +26,7 @@ class MrBomb : public BadGuy { 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); diff --git a/src/badguy/mriceblock.cpp b/src/badguy/mriceblock.cpp index f078f8f0d..60dd66cca 100644 --- a/src/badguy/mriceblock.cpp +++ b/src/badguy/mriceblock.cpp @@ -29,22 +29,14 @@ namespace { } 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; } diff --git a/src/badguy/mriceblock.hpp b/src/badguy/mriceblock.hpp index d3ad9dbb2..35700fa98 100644 --- a/src/badguy/mriceblock.hpp +++ b/src/badguy/mriceblock.hpp @@ -27,7 +27,7 @@ class MrIceBlock : public BadGuy, public Portable { 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); diff --git a/src/badguy/mrrocket.cpp b/src/badguy/mrrocket.cpp index 9bc80ccca..cbe72b5c4 100644 --- a/src/badguy/mrrocket.cpp +++ b/src/badguy/mrrocket.cpp @@ -24,20 +24,14 @@ 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; } diff --git a/src/badguy/mrrocket.hpp b/src/badguy/mrrocket.hpp index 25500ec2b..5cb37b77d 100644 --- a/src/badguy/mrrocket.hpp +++ b/src/badguy/mrrocket.hpp @@ -28,7 +28,7 @@ class MrRocket : public BadGuy { 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); diff --git a/src/badguy/mrtree.cpp b/src/badguy/mrtree.cpp index c4d33f113..2f848ce96 100644 --- a/src/badguy/mrtree.cpp +++ b/src/badguy/mrtree.cpp @@ -32,13 +32,9 @@ static const float POISONIVY_Y_OFFSET = 24; 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 @@ -114,13 +110,13 @@ MrTree::collision_squished(Player& player) 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); } diff --git a/src/badguy/nolok_01.cpp b/src/badguy/nolok_01.cpp index 65b4f14f0..f03a31fb6 100644 --- a/src/badguy/nolok_01.cpp +++ b/src/badguy/nolok_01.cpp @@ -33,20 +33,14 @@ static const float WALKSPEED = 90; //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; } @@ -94,8 +88,8 @@ Nolok_01::active_update(float elapsed_time) } 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; diff --git a/src/badguy/nolok_01.hpp b/src/badguy/nolok_01.hpp index 2a0cdf09e..460d05e93 100644 --- a/src/badguy/nolok_01.hpp +++ b/src/badguy/nolok_01.hpp @@ -27,7 +27,7 @@ class Nolok_01 : public BadGuy { 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); diff --git a/src/badguy/plant.cpp b/src/badguy/plant.cpp index 0f1cce40c..d45200855 100644 --- a/src/badguy/plant.cpp +++ b/src/badguy/plant.cpp @@ -25,11 +25,8 @@ static const float WALKSPEED = 80; 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; } diff --git a/src/badguy/poisonivy.cpp b/src/badguy/poisonivy.cpp index 9a30f6224..e442a9a0b 100644 --- a/src/badguy/poisonivy.cpp +++ b/src/badguy/poisonivy.cpp @@ -24,20 +24,14 @@ 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; } diff --git a/src/badguy/poisonivy.hpp b/src/badguy/poisonivy.hpp index 0005eaa34..a24cfeb53 100644 --- a/src/badguy/poisonivy.hpp +++ b/src/badguy/poisonivy.hpp @@ -26,7 +26,7 @@ class PoisonIvy : public BadGuy { 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); diff --git a/src/badguy/rocketexplosion.cpp b/src/badguy/rocketexplosion.cpp index 0d0adb73b..dcc612014 100644 --- a/src/badguy/rocketexplosion.cpp +++ b/src/badguy/rocketexplosion.cpp @@ -24,11 +24,8 @@ 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(); diff --git a/src/badguy/skullyhop.cpp b/src/badguy/skullyhop.cpp index 6dc1074da..9282d29ea 100644 --- a/src/badguy/skullyhop.cpp +++ b/src/badguy/skullyhop.cpp @@ -30,20 +30,14 @@ namespace { } 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; } diff --git a/src/badguy/skullyhop.hpp b/src/badguy/skullyhop.hpp index 13c7d0699..b3acd8611 100644 --- a/src/badguy/skullyhop.hpp +++ b/src/badguy/skullyhop.hpp @@ -30,7 +30,7 @@ class SkullyHop : public BadGuy { 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); diff --git a/src/badguy/snail.cpp b/src/badguy/snail.cpp index 330846cf7..39664feab 100644 --- a/src/badguy/snail.cpp +++ b/src/badguy/snail.cpp @@ -30,22 +30,14 @@ namespace { } 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; } diff --git a/src/badguy/snail.hpp b/src/badguy/snail.hpp index 7aff914f0..45904e9be 100644 --- a/src/badguy/snail.hpp +++ b/src/badguy/snail.hpp @@ -29,7 +29,7 @@ class Snail : public BadGuy { 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); diff --git a/src/badguy/snowball.cpp b/src/badguy/snowball.cpp index c562ab50b..c20b65f92 100644 --- a/src/badguy/snowball.cpp +++ b/src/badguy/snowball.cpp @@ -24,24 +24,22 @@ 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; } @@ -53,11 +51,11 @@ SnowBall::write(lisp::Writer& writer) 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"); } diff --git a/src/badguy/snowball.hpp b/src/badguy/snowball.hpp index dfd0e8ec5..d13c03fb8 100644 --- a/src/badguy/snowball.hpp +++ b/src/badguy/snowball.hpp @@ -26,7 +26,7 @@ class SnowBall : public BadGuy { 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); @@ -39,7 +39,7 @@ protected: bool collision_squished(Player& player); bool set_direction; Direction initial_direction; - bool fluffy; + //bool fluffy; }; #endif diff --git a/src/badguy/spidermite.cpp b/src/badguy/spidermite.cpp index 3b537b290..c98598493 100644 --- a/src/badguy/spidermite.cpp +++ b/src/badguy/spidermite.cpp @@ -26,20 +26,14 @@ static const float FLYTIME = 1.2; 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); } diff --git a/src/badguy/spidermite.hpp b/src/badguy/spidermite.hpp index 048831ce4..5c1bd5e2a 100644 --- a/src/badguy/spidermite.hpp +++ b/src/badguy/spidermite.hpp @@ -26,7 +26,7 @@ class SpiderMite : public BadGuy { public: SpiderMite(const lisp::Lisp& reader); - SpiderMite(float pos_x, float pos_y); + SpiderMite(const Vector& pos); void activate(); void write(lisp::Writer& writer); diff --git a/src/badguy/spiky.cpp b/src/badguy/spiky.cpp index 9118eea67..fbe27eee8 100644 --- a/src/badguy/spiky.cpp +++ b/src/badguy/spiky.cpp @@ -24,11 +24,8 @@ 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 diff --git a/src/badguy/sspiky.cpp b/src/badguy/sspiky.cpp index 989fe2c80..bd6a0dcd3 100644 --- a/src/badguy/sspiky.cpp +++ b/src/badguy/sspiky.cpp @@ -25,12 +25,8 @@ static const float WALKSPEED = 80; 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 diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index 0a9a145c8..33a160646 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -27,12 +27,8 @@ static const float SHAKE_TIME = .8; 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; } diff --git a/src/badguy/totem.cpp b/src/badguy/totem.cpp index 7d2b932a1..7ec6693cb 100644 --- a/src/badguy/totem.cpp +++ b/src/badguy/totem.cpp @@ -28,14 +28,10 @@ static const float JUMP_ON_SPEED_Y = 400; 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) diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 1a4969b31..a375543d5 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -28,17 +28,12 @@ static const float TRACK_RANGE = 384; /**< at what distance to start tracking th 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) diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index 42dbe4155..c8c717dc3 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -53,11 +53,8 @@ namespace { } 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; @@ -161,7 +158,7 @@ Yeti::be_angry() 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 diff --git a/src/badguy/zeekling.cpp b/src/badguy/zeekling.cpp index e264078f6..65abb0c24 100644 --- a/src/badguy/zeekling.cpp +++ b/src/badguy/zeekling.cpp @@ -26,21 +26,15 @@ #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; diff --git a/src/badguy/zeekling.hpp b/src/badguy/zeekling.hpp index ab88a9afa..11b819923 100644 --- a/src/badguy/zeekling.hpp +++ b/src/badguy/zeekling.hpp @@ -28,7 +28,7 @@ class Zeekling : public BadGuy { 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);