本文整理汇总了C++中MapEntity::get_facing_point方法的典型用法代码示例。如果您正苦于以下问题:C++ MapEntity::get_facing_point方法的具体用法?C++ MapEntity::get_facing_point怎么用?C++ MapEntity::get_facing_point使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapEntity
的用法示例。
在下文中一共展示了MapEntity::get_facing_point方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: is_in_jump_position
/**
* \brief Returns whether an entity is correctly placed to start jumping
* with this jumper.
* \param entity A map entity.
* \return \c true if the entity is correctly placed to start the jump.
*/
bool Jumper::is_in_jump_position(const MapEntity& entity) const {
const int direction8 = get_direction();
if (is_jump_diagonal()) {
// The sensor's shape is a diagonal bar.
return is_point_in_diagonal(entity.get_facing_point((direction8 - 1) / 2))
|| is_point_in_diagonal(entity.get_facing_point((direction8 + 1) % 8 / 2));
}
// The sensor has one of the four main directions.
// Its shape is exactly its rectangle.
const int expected_direction4 = direction8 / 2;
const Rectangle& facing_point = entity.get_facing_point(expected_direction4);
const bool horizontal_jump = is_jump_horizontal();
return overlaps(facing_point.get_x() + (horizontal_jump ? 0 : -8),
facing_point.get_y() + (horizontal_jump ? -8 : 0))
&& overlaps(facing_point.get_x() + (horizontal_jump ? 0 : 7),
facing_point.get_y() + (horizontal_jump ? 7 : 0));
}