本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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();
//.........这里部分代码省略.........
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例14: set_target
/**
* @brief Sets the entity to target with this movement.
*/
void PathFindingMovement::set_target(MapEntity& target) {
this->target = ⌖
target.increment_refcount();
next_recomputation_date = System::now() + 100;
}
示例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);
}