コード例 #1
0
ファイル: DynamicTile.cpp プロジェクト: joshjordan/solarus
/**
 * \brief Returns whether this tile is an obstacle for the specified entity.
 * \param other an entity
 * \return true if this tile is an obstacle for the entity
 */
bool DynamicTile::is_obstacle_for(const MapEntity& other) const {

  // TODO normally, this function can be removed since there is already
  // a modified ground
  bool result = false;
  switch (get_modified_ground()) {

    case GROUND_WALL:
    case GROUND_LOW_WALL:
    case GROUND_WALL_TOP_RIGHT:
    case GROUND_WALL_TOP_LEFT:
    case GROUND_WALL_BOTTOM_LEFT:
    case GROUND_WALL_BOTTOM_RIGHT:
    case GROUND_WALL_TOP_RIGHT_WATER:
    case GROUND_WALL_TOP_LEFT_WATER:
    case GROUND_WALL_BOTTOM_LEFT_WATER:
    case GROUND_WALL_BOTTOM_RIGHT_WATER:
      result = true;
      break;

    case GROUND_EMPTY:
    case GROUND_TRAVERSABLE:
    case GROUND_SHALLOW_WATER:
    case GROUND_DEEP_WATER:
    case GROUND_GRASS:
    case GROUND_HOLE:
    case GROUND_LAVA:
    case GROUND_PRICKLE:
    case GROUND_LADDER:
    case GROUND_ICE:
      result = false;
      break;
  }
  return result;
}
コード例 #2
0
ファイル: Destructible.cpp プロジェクト: MilkshakeCat/solarus
/**
 * \brief Sets the appropriate collisions modes.
 *
 * This depends on whether the object is an obstacle, can be cut
 * or can explode.
 */
void Destructible::update_collision_modes() {

  // Reset previous collision modes.
  set_collision_modes(0);

  // Sets the new ones.
  if (get_modified_ground() == Ground::WALL) {
    // The object is an obstacle.
    // Set the facing collision mode to allow the hero to look at it.
    add_collision_mode(COLLISION_FACING);
  }

  if (get_can_be_cut()
      || get_can_explode()) {
    add_collision_mode(COLLISION_SPRITE);
  }
}
コード例 #3
0
ファイル: Destructible.cpp プロジェクト: MilkshakeCat/solarus
/**
 * \brief Returns whether this entity is an obstacle for another one.
 * \param other Another entity.
 * \return \c true if this entity is an obstacle for the other one.
 */
bool Destructible::is_obstacle_for(MapEntity& other) {

  return get_modified_ground() == Ground::WALL
      && !is_being_cut
      && other.is_destructible_obstacle(*this);
}