Example #1
0
/**
 * \copydoc Entity::notify_created
 */
void Block::notify_created() {

  Entity::notify_created();

  check_collision_with_detectors();
  update_ground_below();
}
Example #2
0
/**
 * \brief Sets the map.
 *
 * Warning: when this function is called during the map initialization,
 * the current map of the game is still the old one.
 *
 * \param map The map.
 */
void Block::set_map(Map& map) {

  Detector::set_map(map);
  if (map.is_loaded()) {
    // We are not during the map initialization phase.
    check_collision_with_detectors(false);
    update_ground_below();
  }
}
Example #3
0
/**
 * \copydoc Entity::notify_created
 */
void Pickable::notify_created() {

  Detector::notify_created();

  update_ground_below();
  notify_ground_below_changed();  // Necessary if on empty ground.

  // This entity and the map are now both ready. Notify the Lua item.
  EquipmentItem& item = get_equipment().get_item(treasure.get_item_name());
  item.notify_pickable_appeared(*this);
}
Example #4
0
/**
 * \brief Notifies the block that it has just moved.
 */
void Block::notify_position_changed() {

  // now we know that the block moves at least of 1 pixel:
  // we can play the sound
  if (get_movement() != NULL && !sound_played) {
    Sound::play("hero_pushes");
    sound_played = true;
  }

  check_collision_with_detectors(false);
  update_ground_below();

  if (are_movement_notifications_enabled()) {
    get_lua_context().entity_on_position_changed(*this, get_xy(), get_layer());
  }
}