当前位置: 首页>>代码示例>>C++>>正文


C++ MapEntity::is_shallow_water_obstacle方法代码示例

本文整理汇总了C++中MapEntity::is_shallow_water_obstacle方法的典型用法代码示例。如果您正苦于以下问题:C++ MapEntity::is_shallow_water_obstacle方法的具体用法?C++ MapEntity::is_shallow_water_obstacle怎么用?C++ MapEntity::is_shallow_water_obstacle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MapEntity的用法示例。


在下文中一共展示了MapEntity::is_shallow_water_obstacle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_collision_with_ground

/**
 * \brief Tests whether a point collides with the ground of the map.
 *
 * The ground is the terrain of the point. It is defined by the tiles and
 * by the presence of entities that may change it
 * (like dynamic tiles and destructible items).
 *
 * This method also returns true if the point is outside the map.
 *
 * \param layer Layer of the point.
 * \param x X of the point in pixels.
 * \param y Y of the point in pixels.
 * \param entity_to_check The entity to check (used to decide what grounds are
 * considered as obstacle).
 * \param [out] found_diagonal_wall \c true if the ground under this point was
 * a diagonal wall, unchanged otherwise.
 * Your algorithm may decide to check more points if there is a diagonal wall.
 * \return \c true if this point is on an obstacle.
 */
bool Map::test_collision_with_ground(
    Layer layer,
    int x,
    int y,
    const MapEntity& entity_to_check,
    bool& found_diagonal_wall) const {

  bool on_obstacle = false;
  int x_in_tile, y_in_tile;

  // If the point is outside the map, this is an obstacle.
  if (test_collision_with_border(x, y)) {
    return true;
  }

  // Get the ground property under this point.
  Ground ground = get_ground(layer, x, y);
  switch (ground) {

  case GROUND_EMPTY:
  case GROUND_TRAVERSABLE:
  case GROUND_GRASS:
  case GROUND_ICE:
    // The square is not an obstacle.
    on_obstacle = false;
    break;

  case GROUND_WALL:
    // The square is entirely an obstacle.
    on_obstacle = true;
    break;

  case GROUND_WALL_TOP_RIGHT:
  case GROUND_WALL_TOP_RIGHT_WATER:
    // The upper right half of the square is an obstacle
    // so we have to test the position of the point in the square.
    x_in_tile = x & 7;
    y_in_tile = y & 7;
    on_obstacle = y_in_tile <= x_in_tile;
    found_diagonal_wall = true;
    break;

  case GROUND_WALL_TOP_LEFT:
  case GROUND_WALL_TOP_LEFT_WATER:
    // Same thing.
    x_in_tile = x & 7;
    y_in_tile = y & 7;
    on_obstacle = y_in_tile <= 7 - x_in_tile;
    found_diagonal_wall = true;
    break;

  case GROUND_WALL_BOTTOM_LEFT:
  case GROUND_WALL_BOTTOM_LEFT_WATER:
    x_in_tile = x & 7;
    y_in_tile = y & 7;
    on_obstacle = y_in_tile >= x_in_tile;
    found_diagonal_wall = true;
    break;

  case GROUND_WALL_BOTTOM_RIGHT:
  case GROUND_WALL_BOTTOM_RIGHT_WATER:
    x_in_tile = x & 7;
    y_in_tile = y & 7;
    on_obstacle = y_in_tile >= 7 - x_in_tile;
    found_diagonal_wall = true;
    break;

  case GROUND_LOW_WALL:
    on_obstacle = entity_to_check.is_low_wall_obstacle();
    break;

  case GROUND_SHALLOW_WATER:
    on_obstacle = entity_to_check.is_shallow_water_obstacle();
    break;

  case GROUND_DEEP_WATER:
    on_obstacle = entity_to_check.is_deep_water_obstacle();
    break;

  case GROUND_HOLE:
    on_obstacle = entity_to_check.is_hole_obstacle();
//.........这里部分代码省略.........
开发者ID:abenavente406,项目名称:solarus,代码行数:101,代码来源:Map.cpp


注:本文中的MapEntity::is_shallow_water_obstacle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。