static const float FISH_WAIT_TIME = 1;
Fish::Fish(const lisp::Lisp& reader)
- : BadGuy(reader, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
+ : BadGuy(reader, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
{
physic.enable_gravity(true);
}
Fish::Fish(const Vector& pos)
- : BadGuy(pos, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
+ : BadGuy(pos, "images/creatures/fish/fish.sprite", LAYER_TILES-1), stop_y(0)
{
physic.enable_gravity(true);
}
if(waiting.started())
return;
- BadGuy::draw(context);
+ if (get_state() == STATE_FALLING) {
+ sprite->set_action("down");
+ sprite->draw(context, get_pos(), layer);
+ }
+ else if (get_state() == STATE_ACTIVE) {
+ sprite->draw(context, get_pos(), layer);
+ }
}
HitResponse
// stop when we have reached the stop position
if (get_pos().y >= stop_y) {
- start_waiting();
+ if(!frozen)
+ start_waiting();
movement = Vector(0, 0);
}
if(waiting.check()) {
jump();
}
-
+
// set sprite
- sprite->set_action(physic.get_velocity_y() < 0 ? "normal" : "down");
-
+ if(!frozen)
+ sprite->set_action(physic.get_velocity_y() < 0 ? "normal" : "down");
+
// we can't afford flying out of the tilemap, 'cause the engine would remove us.
if ((get_pos().y - 31.8) < 0) // too high, let us fall
{
Fish::start_waiting()
{
waiting.start(FISH_WAIT_TIME);
- set_group(COLGROUP_DISABLED);
+ set_colgroup_active(COLGROUP_DISABLED);
physic.enable_gravity(false);
physic.set_velocity_y(0);
}
{
physic.set_velocity_y(FISH_JUMP_POWER);
physic.enable_gravity(true);
- set_group(COLGROUP_MOVING);
+ set_colgroup_active(COLGROUP_MOVING);
+}
+
+void
+Fish::freeze()
+{
+ BadGuy::freeze();
+ sprite->set_action(physic.get_velocity_y() < 0 ? "iced" : "iced-down");
+ waiting.stop();
+}
+
+void
+Fish::unfreeze()
+{ // does this happen at all? (or do fishes die when they fall frozen?)
+ BadGuy::unfreeze();
+ start_waiting();
+}
+
+bool
+Fish::is_freezable() const
+{
+ return true;
}
IMPLEMENT_FACTORY(Fish, "fish")