#include "spidermite.hpp"
-static const float FLYTIME = 1.2;
-static const float FLYSPEED = -100.0;
+static const float FLYTIME = 1.2f;
+static const float FLYSPEED = -100.0f;
SpiderMite::SpiderMite(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/spidermite/spidermite.sprite")
+ : BadGuy(reader, "images/creatures/spidermite/spidermite.sprite")
{
physic.enable_gravity(false);
}
SpiderMite::SpiderMite(const Vector& pos)
- : BadGuy(pos, "images/creatures/spidermite/spidermite.sprite")
+ : BadGuy(pos, "images/creatures/spidermite/spidermite.sprite")
{
physic.enable_gravity(false);
}
writer.end_list("spidermite");
}
-void
-SpiderMite::activate()
+void
+SpiderMite::initialize()
{
sprite->set_action(dir == LEFT ? "left" : "right");
mode = FLY_UP;
}
bool
-SpiderMite::collision_squished(Player& player)
+SpiderMite::collision_squished(GameObject& object)
{
sprite->set_action(dir == LEFT ? "squished-left" : "squished-right");
- kill_squished(player);
+ kill_squished(object);
return true;
}
-HitResponse
-SpiderMite::collision_solid(GameObject& , const CollisionHit& hit)
+void
+SpiderMite::collision_solid(const CollisionHit& hit)
{
- if(fabsf(hit.normal.y) > 1.5) { // hit floor or roof?
+ if(hit.top || hit.bottom) { // hit floor or roof?
physic.set_velocity_y(0);
}
-
- return CONTINUE;
}
void
-SpiderMite::active_update(float elapsed_time)
+SpiderMite::active_update(float elapsed_time)
{
if(timer.check()) {
if(mode == FLY_UP) {