}
}
-HitResponse
-Stalactite::collision_solid(GameObject& , const CollisionHit& hit)
+void
+Stalactite::squish()
{
- if(state != STALACTITE_FALLING && state != STALACTITE_SQUISHED)
- return FORCE_MOVE;
-
- if(hit.normal.y < .9) { // hit floor?
- state = STALACTITE_SQUISHED;
- set_group(COLGROUP_MOVING_ONLY_STATIC);
+ state = STALACTITE_SQUISHED;
+ set_group(COLGROUP_MOVING_ONLY_STATIC);
+ sprite->set_action("squished");
+ if(!timer.started())
+ timer.start(SQUISH_TIME);
+}
+
+void
+Stalactite::collision_solid(const CollisionHit& hit)
+{
+ if(state == STALACTITE_FALLING) {
+ if (hit.bottom) squish();
+ }
+ if(state == STALACTITE_SQUISHED) {
physic.set_velocity_y(0);
- sprite->set_action("squished");
- if(!timer.started())
- timer.start(SQUISH_TIME);
}
-
- return CONTINUE;
}
HitResponse
-Stalactite::collision_player(Player& player, const CollisionHit& )
+Stalactite::collision_player(Player& player)
{
if(state != STALACTITE_SQUISHED) {
player.kill(false);
return FORCE_MOVE;
}
+HitResponse
+Stalactite::collision_badguy(BadGuy& other, const CollisionHit& hit)
+{
+ if (state == STALACTITE_SQUISHED) return FORCE_MOVE;
+ if (state != STALACTITE_FALLING) return BadGuy::collision_badguy(other, hit);
+
+ if (other.is_freezable()) {
+ other.freeze();
+ } else {
+ other.kill_fall();
+ }
+
+ remove_me();
+
+ return FORCE_MOVE;
+}
+
void
Stalactite::kill_fall()
{
{
if(get_state() != STATE_ACTIVE)
return;
-
+
if(state == STALACTITE_SHAKING) {
sprite->draw(context, get_pos() + Vector(systemRandom.rand(-3,3), 0), LAYER_OBJECTS);
} else {