Ejemplo n.º 1
0
void
BadGuy::collision_tile(uint32_t tile_attributes)
{
  // Don't kill badguys that have already been killed
  if (!is_active()) return;

  if (tile_attributes & Tile::WATER && !is_in_water())
  {
    m_in_water = true;
    SoundManager::current()->play("sounds/splash.ogg", get_pos());
  }
  if (!(tile_attributes & Tile::WATER) && is_in_water())
  {
    m_in_water = false;
  }

  if (tile_attributes & Tile::HURTS && is_hurtable()) {
    if (tile_attributes & Tile::FIRE) {
      if (is_flammable()) ignite();
    }
    else if (tile_attributes & Tile::ICE) {
      if (is_freezable()) freeze();
    }
    else {
      kill_fall();
    }
  }
}
Ejemplo n.º 2
0
void
Kugelblitz::active_update(float elapsed_time)
{
  if (lifetime.check()) {
    explode();
  }
  else {
    if (groundhit_pos_set) {
      if (movement_timer.check()) {
        if (direction == 1) direction = -1; else direction = 1;
        int speed = (BASE_SPEED + (gameRandom.rand(RAND_SPEED))) * direction;
        physic.set_velocity_x(speed);
        movement_timer.start(MOVETIME);
      }
    }

    if (is_in_water()) {
      Sector::current()->add_object( std::make_shared<Electrifier>(75,1421,1.5));
      Sector::current()->add_object( std::make_shared<Electrifier>(76,1422,1.5));
      explode();
    }
  }
  BadGuy::active_update(elapsed_time);
}