static const float X_OFFSCREEN_DISTANCE = 1280;
static const float Y_OFFSCREEN_DISTANCE = 800;
-static const int LAYER_FALLING = 500;
BadGuy::BadGuy(const Vector& pos, const std::string& sprite_name_, int layer_) :
MovingSprite(pos, sprite_name_, layer_, COLGROUP_DISABLED),
start_dir(AUTO),
frozen(false),
ignited(false),
+ in_water(false),
dead_script(),
state(STATE_INIT),
is_active_flag(),
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
+ SoundManager::current()->preload("sounds/splash.wav");
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
start_dir(direction),
frozen(false),
ignited(false),
+ in_water(false),
dead_script(),
state(STATE_INIT),
is_active_flag(),
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
+ SoundManager::current()->preload("sounds/splash.wav");
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
start_dir(AUTO),
frozen(false),
ignited(false),
+ in_water(false),
dead_script(),
state(STATE_INIT),
is_active_flag(),
SoundManager::current()->preload("sounds/squish.wav");
SoundManager::current()->preload("sounds/fall.wav");
+ SoundManager::current()->preload("sounds/splash.wav");
dir = (start_dir == AUTO) ? LEFT : start_dir;
}
// Don't kill badguys that have already been killed
if (!is_active()) return;
+ if(tile_attributes & Tile::WATER && !is_in_water())
+ {
+ in_water = true;
+ SoundManager::current()->play("sounds/splash.wav", get_pos());
+ }
+ if(!(tile_attributes & Tile::WATER) && is_in_water())
+ {
+ in_water = false;
+ }
+
if(tile_attributes & Tile::HURTS) {
if (tile_attributes & Tile::FIRE) {
if (is_flammable()) ignite();
// hit from above?
if (player->get_bbox().p2.y < (bbox.p1.y + 16)) {
+ if(player->is_stone()) {
+ kill_fall();
+ return FORCE_MOVE;
+ }
if(collision_squished(*player)) {
return FORCE_MOVE;
}
}
+ if(player->is_stone()) {
+ collision_solid(hit);
+ return FORCE_MOVE;
+ }
+
return collision_player(*player, hit);
}
physic.set_acceleration_y(0);
physic.enable_gravity(true);
set_state(STATE_FALLING);
- layer = LAYER_FALLING;
+
+ // Set the badguy layer to be the foremost, so that
+ // this does not reveal secret tilemaps:
+ layer = Sector::current()->get_foremost_layer() + 1;
// start dead-script
run_dead_script();
return frozen;
}
+bool
+BadGuy::is_in_water() const
+{
+ return in_water;
+}
+
void
BadGuy::ignite()
{