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


C++ MapEntity类代码示例

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


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

示例1: test_collision_custom

/**
 * @brief Returns whether an entity collides with this detector with respect to a custom rule.
 * @param entity the entity
 * @return true if the entity's collides with this detector with respect to the custom rule
 */
bool DynamicTile::test_collision_custom(MapEntity &entity) {

  // we must test the same coordinates as non-dynamic tiles (see Hero::get_ground_point())
  return overlaps(entity.get_x(), entity.get_y() - 2);
}
开发者ID:Valodim,项目名称:solarus,代码行数:10,代码来源:DynamicTile.cpp

示例2: notify_collision

/**
 * @brief Notifies this entity that another sprite is overlapping it.
 *
 * This function is called by check_collision(MapEntity*, Sprite*) when another entity's
 * sprite overlaps a sprite of this detector.
 *
 * @param other_entity the entity overlapping this detector
 * @param other_sprite the sprite of other_entity that is overlapping this detector
 * @param this_sprite the sprite of this detector that is overlapping the other entity's sprite
 */
void CrystalSwitch::notify_collision(MapEntity &other_entity, Sprite &other_sprite, Sprite &this_sprite) {
  other_entity.notify_collision_with_crystal_switch(*this, other_sprite);
}
开发者ID:ziz,项目名称:solarus,代码行数:13,代码来源:CrystalSwitch.cpp

示例3: is_obstacle_for

/**
 * \brief Returns whether this entity is an obstacle for another one.
 * \param other another entity
 * \return true if this entity is an obstacle for the other one
 */
bool Sensor::is_obstacle_for(const MapEntity& other) const {

  return other.is_sensor_obstacle(*this);
}
开发者ID:joshjordan,项目名称:solarus,代码行数:9,代码来源:Sensor.cpp

示例4: 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:j4b0l,项目名称:solarus,代码行数:101,代码来源:Map.cpp

示例5: notify_collision

/**
 * \copydoc Detector::notify_collision(MapEntity&, Sprite&, Sprite&)
 */
void Crystal::notify_collision(MapEntity& other_entity, Sprite& /* this_sprite */, Sprite& other_sprite) {
  other_entity.notify_collision_with_crystal(*this, other_sprite);
}
开发者ID:Fordi,项目名称:Solarus-PSP,代码行数:6,代码来源:Crystal.cpp

示例6: notify_collision

/**
 * \brief Notifies the enemy that a collision was just detected with another entity
 * \param entity_overlapping the other entity
 * \param collision_mode the collision mode that detected the collision
 */
void Enemy::notify_collision(MapEntity &entity_overlapping, CollisionMode collision_mode) {

  entity_overlapping.notify_collision_with_enemy(*this);
}
开发者ID:joshjordan,项目名称:solarus,代码行数:9,代码来源:Enemy.cpp

示例7: is_obstacle_for

/**
 * \brief Returns whether this entity is an obstacle for another one.
 * \param other another entity
 * \return true
 */
bool Block::is_obstacle_for(const MapEntity& other) const {

  return other.is_block_obstacle(*this);
}
开发者ID:bgalok,项目名称:solarus,代码行数:9,代码来源:Block.cpp

示例8: notify_collision

/**
 * \brief This function is called by the engine when there is a collision with another entity.
 * \param entity_overlapping the entity overlapping the detector
 * \param collision_mode the collision mode that detected the collision
 */
void Block::notify_collision(MapEntity& entity_overlapping, CollisionMode collision_mode) {

  entity_overlapping.notify_collision_with_block(*this);
}
开发者ID:bgalok,项目名称:solarus,代码行数:9,代码来源:Block.cpp

示例9: notify_collision

/**
 * @brief Notifies this entity that a pixel-perfect collision was just detected with another sprite.
 *
 * This function is called by check_collision(MapEntity*, Sprite*) when another entity's
 * sprite overlaps a sprite of this detector.
 *
 * @param other_entity the entity overlapping this detector
 * @param other_sprite the sprite of other_entity that is overlapping this detector
 * @param this_sprite the sprite of this detector that is overlapping the other entity's sprite
 */
void Explosion::notify_collision(MapEntity &other_entity, Sprite &other_sprite, Sprite &this_sprite) {

  other_entity.notify_collision_with_explosion(*this, other_sprite);
}
开发者ID:Aerospyke,项目名称:solarus,代码行数:14,代码来源:Explosion.cpp

示例10: is_obstacle_for

/**
 * \brief Returns whether this entity is an obstacle for another one
 * when it is enabled.
 * \param other another entity
 * \return true if this entity is an obstacle for the other one
 */
bool Wall::is_obstacle_for(MapEntity& other) {

  const auto it = entity_types_stopped.find(other.get_type());
  return it != entity_types_stopped.end();
}
开发者ID:cooljith91112,项目名称:solarus,代码行数:11,代码来源:Wall.cpp

示例11: notify_collision

/**
 * \brief This function is called by the engine when an entity overlaps the destructible item.
 *
 * If the entity is the hero, we allow him to lift the item.
 *
 * \param entity_overlapping the entity overlapping the detector
 * \param collision_mode the collision mode that detected the collision
 */
void Destructible::notify_collision(MapEntity &entity_overlapping, CollisionMode collision_mode) {

  entity_overlapping.notify_collision_with_destructible(*this, collision_mode);
}
开发者ID:Arvek,项目名称:SOLARME,代码行数:12,代码来源:Destructible.cpp

示例12: test_collision_custom

/**
 * \brief Tests whether an entity's collides with this entity.
 *
 * This custom collision test is used for destructible items that change the ground drawn under the hero.
 *
 * \param entity an entity
 * \return true if the entity's collides with this entity
 */
bool Destructible::test_collision_custom(MapEntity &entity) {
  return overlaps(entity.get_x(), entity.get_y() - 2);
}
开发者ID:Arvek,项目名称:SOLARME,代码行数:11,代码来源:Destructible.cpp

示例13: is_obstacle_for

/**
 * \brief Returns whether this entity is an obstacle for another one.
 *
 * For a destructible item, this does not depend on the other
 * entity but only on the subtype of destructible item.
 *
 * \param other another entity
 * \return true if this entity is an obstacle for others
 */
bool Destructible::is_obstacle_for(const MapEntity& other) const {
  return features[subtype].can_be_lifted && !is_being_cut && other.is_destructible_obstacle(*this);
}
开发者ID:Arvek,项目名称:SOLARME,代码行数:12,代码来源:Destructible.cpp

示例14: set_target

/**
 * @brief Sets the entity to target with this movement.
 */
void PathFindingMovement::set_target(MapEntity& target) {

  this->target = &target;
  target.increment_refcount();
  next_recomputation_date = System::now() + 100;
}
开发者ID:lambdaloop,项目名称:solarus,代码行数:9,代码来源:PathFindingMovement.cpp

示例15: test_collision_rectangle

/**
 * \brief Returns whether an entity's rectangle is overlapping the detector's rectangle.
 *
 * This method is called by check_collision(MapEntity*) when the detector's collision
 * mode is COLLISION_RECTANGLE.
 *
 * \param entity the entity
 * \return true if the entity's rectangle is overlapping the detector's rectangle
 */
bool Detector::test_collision_rectangle(MapEntity& entity) {

  return entity.overlaps(*this);
}
开发者ID:j4b0l,项目名称:solarus,代码行数:13,代码来源:Detector.cpp


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