本文整理汇总了C++中MapEntity::is_aligned_to_grid方法的典型用法代码示例。如果您正苦于以下问题:C++ MapEntity::is_aligned_to_grid方法的具体用法?C++ MapEntity::is_aligned_to_grid怎么用?C++ MapEntity::is_aligned_to_grid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapEntity
的用法示例。
在下文中一共展示了MapEntity::is_aligned_to_grid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start_next_elementary_move
/**
* \brief Starts the next 8-pixel trajectory of the path movement.
*
* This function is called when an 8-pixel trajectory of the movement is finished,
* or when the movement is restarted.
* Before starting the 8-pixel move, if the property must_be_aligned is true,
* the entity's top-left corner tries to get aligned with the 8*8 squares of the grid.
*/
void PathMovement::start_next_elementary_move() {
MapEntity* entity = get_entity();
// don't move while the entity is unknown
if (entity == NULL) {
return;
}
// before starting the move, check that the entity is aligned with the 8*8 squares grid if necessary
if (snap_to_grid && !entity->is_aligned_to_grid()) {
// the entity has to be aligned but is not
snap();
}
// start the next step if we are ready
if (!snap_to_grid || entity->is_aligned_to_grid()) {
snapping = false;
if (remaining_path.empty()) {
// the path is finished
if (loop) {
// if the property 'loop' is true, repeat the same path again
remaining_path = initial_path;
}
else if (!is_stopped()) {
// the movement is finished: stop the entity
stop();
}
}
if (!remaining_path.empty()) {
// normal case: there is a next trajectory to do
current_direction = remaining_path[0] - '0';
Debug::check_assertion(current_direction >= 0 && current_direction < 8,
std::string("Invalid path '") + initial_path + "' (bad direction '"
+ remaining_path[0] + "')"
);
PixelMovement::set_delay(speed_to_delay(speed, current_direction));
PixelMovement::set_trajectory(elementary_moves[current_direction]);
remaining_path = remaining_path.substr(1);
}
}
}
示例2: map
/**
* \brief Constructor.
* \param map the map
* \param source_entity the entity that will move from the starting point to the target
* (its position must be aligned on the map grid)
* \param target_entity the target entity (its size must be 16*16)
*/
PathFinding::PathFinding(
Map& map,
MapEntity& source_entity,
MapEntity& target_entity):
map(map),
source_entity(source_entity),
target_entity(target_entity) {
Debug::check_assertion(source_entity.is_aligned_to_grid(),
"The source must be aligned on the map grid");
}