Exemplo n.º 1
0
/**
 * \copydoc Entity::notify_creating
 */
void Teletransporter::notify_creating() {

  Entity::notify_creating();

  int x = get_x();
  int y = get_y();

  // Compute the destination side in case the destination name is "_side"
  // or becomes it later.
  if (get_width() == 16 && x == -16) {
    destination_side = 0;
  }
  else if (get_width() == 16 && x == get_map().get_width()) {
    destination_side = 2;
  }
  else if (get_height() == 16 && y == -16) {
    destination_side = 3;
  }
  else if (get_height() == 16 && y == get_map().get_height()) {
    destination_side = 1;
  }

  if (destination_side != -1) {
    set_layer_independent_collisions(true);
    transition_direction = (destination_side + 2) % 4;
  }
}
Exemplo n.º 2
0
/**
 * \brief Creates a new separator.
 * \param name Name of the entity to create.
 * \param layer Layer of the entity to create on the map.
 * \param xy Coordinate of the entity to create.
 * \param size Size of the separator.
 * A width of 16 means a vertical separator and a height of 16 means a
 * horizontal one.
 */
Separator::Separator(
    const std::string& name,
    Layer layer,
    const Point& xy,
    const Size& size
):
  Detector(COLLISION_CUSTOM, name, layer, xy, size) {

  Debug::check_assertion((size.width == 16 && size.height > 16)
      || (size.width > 16 && size.height == 16), "Invalid separator size");

  set_layer_independent_collisions(true);
}