本文整理汇总了C++中DungeonMap::isWalkable方法的典型用法代码示例。如果您正苦于以下问题:C++ DungeonMap::isWalkable方法的具体用法?C++ DungeonMap::isWalkable怎么用?C++ DungeonMap::isWalkable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DungeonMap
的用法示例。
在下文中一共展示了DungeonMap::isWalkable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findNextRandomGoal
void ZombieDarkEntity::findNextRandomGoal()
{
currentTile = getCurrentTile();
DungeonMap* dMap = game().getCurrentMap();
int backDirection = 0;
switch (currentDirection)
{
case 4: backDirection = 6; break;
case 6: backDirection = 4; break;
case 2: backDirection = 8; break;
case 8: backDirection = 2; break;
default: break;
}
bool ok = false;
{
int r = 0;
while (!ok)
{
r++;
if (r == 150) // watchdog
ok = true;
else if (r == 40)
{
backDirection = 5;
}
int newDir = rand() % 4;
if (newDir == 0)
{
if (backDirection != 4 && currentTile.x > 1 && (currentTile.y % 2 != 0) && dMap->isWalkable(currentTile.x - 1, currentTile.y))
{
currentDirection = 4;
targetTile = IntCoord(currentTile.x - 1, currentTile.y);
ok = true;
}
}
else if (newDir == 1)
{
if (backDirection != 6 && currentTile.x < MAP_WIDTH - 2 && (currentTile.y % 2 != 0) && dMap->isWalkable(currentTile.x + 1, currentTile.y))
{
currentDirection = 6;
targetTile = IntCoord(currentTile.x + 1, currentTile.y);
ok = true;
}
}
else if (newDir == 2)
{
if (backDirection != 8 && currentTile.y > 1 && (currentTile.x % 2 != 0) && dMap->isWalkable(currentTile.x, currentTile.y - 1))
{
currentDirection = 8;
targetTile = IntCoord(currentTile.x, currentTile.y - 1);
ok = true;
}
}
else
{
if (backDirection != 2 && currentTile.y < MAP_HEIGHT - 2 && (currentTile.x % 2 != 0) && dMap->isWalkable(currentTile.x, currentTile.y + 1))
{
currentDirection = 2;
targetTile = IntCoord(currentTile.x, currentTile.y + 1);
ok = true;
}
}
}
}
switch (currentDirection)
{
case 4: velocity.x = - creatureSpeed; velocity.y = 0.0f; break;
case 6: velocity.x = + creatureSpeed; velocity.y = 0.0f; break;
case 2: velocity.y = + creatureSpeed; velocity.x = 0.0f; break;
case 8: velocity.y = - creatureSpeed; velocity.x = 0.0f; break;
default: break;
}
nextFacingDirection = currentDirection;
}