本文整理汇总了C++中AStarNode::getXCoord方法的典型用法代码示例。如果您正苦于以下问题:C++ AStarNode::getXCoord方法的具体用法?C++ AStarNode::getXCoord怎么用?C++ AStarNode::getXCoord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AStarNode
的用法示例。
在下文中一共展示了AStarNode::getXCoord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canMoveHorizontal
bool AStar::canMoveHorizontal(const AStarNode& current, const AStarNode& destination) const
{
if (this->isValidNode(destination.getXCoord(), destination.getYCoord()) && !destination.getWall())
{
return true;
}
else
{
return false;
}
}
示例2: canMoveDiagonal
bool AStar::canMoveDiagonal(const AStarNode& current, const AStarNode& destination) const //yeah double check this
{
if (this->isValidNode(destination.getXCoord(), destination.getYCoord()))
{
//upper left & upper right diags
if (destination.getXCoord() == current.getXCoord() - 1)
{
//upper left
if ((this->isValidNode(destination.getXCoord()-1, destination.getYCoord())&&(!this->getNode(destination.getXCoord() - 1, destination.getYCoord())->getWall())))
{
if (destination.getYCoord() == current.getYCoord() - 1)
{
return (this->isValidNode(current.getXCoord()-1, current.getYCoord()-1) && (this->getNode(current.getXCoord() - 1, current.getYCoord() - 1)->getWall()));
}
else if (destination.getYCoord() == current.getYCoord() + 1)
{
return (this->isValidNode(current.getXCoord() - 1, current.getYCoord() + 1) && (this->getNode(current.getXCoord() - 1, current.getYCoord() + 1)->getWall()));
}
else
{
return false;
}
}
else
{
return false;
}
}
//lower left & lower right diags
else if (destination.getXCoord() == current.getXCoord() + 1)
{
if ((this->isValidNode(destination.getXCoord() + 1, destination.getYCoord()) && !this->getNode(destination.getXCoord() + 1, destination.getYCoord())->getWall()))
{
if (destination.getYCoord() == current.getYCoord() - 1)
{
return (this->isValidNode(current.getXCoord() + 1, current.getYCoord() - 1) && this->getNode(current.getXCoord() + 1, current.getYCoord() - 1));
}
else if (destination.getYCoord() == current.getYCoord() + 1)
{
return (this->isValidNode(current.getXCoord() + 1, current.getYCoord() + 1) && this->getNode(current.getXCoord() + 1, current.getYCoord() + 1));
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}