#include <config.h>
#include "mrrocket.hpp"
+#include "object/explosion.hpp"
static const float SPEED = 200;
MrRocket::MrRocket(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/mr_rocket/mr_rocket.sprite")
+ : BadGuy(reader, "images/creatures/mr_rocket/mr_rocket.sprite")
{
}
MrRocket::MrRocket(const Vector& pos, Direction d)
- : BadGuy(pos, d, "images/creatures/mr_rocket/mr_rocket.sprite")
+ : BadGuy(pos, d, "images/creatures/mr_rocket/mr_rocket.sprite")
{
}
}
void
-MrRocket::activate()
+MrRocket::initialize()
{
- physic.vx = (dir == LEFT ? -SPEED : SPEED);
- physic.gravity_enabled = false;
+ physic.set_velocity_x(dir == LEFT ? -SPEED : SPEED);
+ physic.enable_gravity(false);
sprite->set_action(dir == LEFT ? "left" : "right");
}
MrRocket::active_update(float elapsed_time)
{
if (collision_timer.check()) {
- Sector::current()->add_object(new RocketExplosion(get_pos(), dir));
+ Sector::current()->add_object(new Explosion(get_bbox().get_middle()));
remove_me();
}
else if (!collision_timer.started()) {
MrRocket::collision_solid(const CollisionHit& hit)
{
if(hit.top || hit.bottom) {
- physic.vy = 0;
+ physic.set_velocity_y(0);
} else if(hit.left || hit.right) {
sprite->set_action(dir == LEFT ? "collision-left" : "collision-right");
- physic.vx = 0;
- collision_timer.start(0.2, true);
+ physic.set_velocity_x(0);
+ collision_timer.start(0.2f, true);
}
}