
Untitled
By: a guest on
May 1st, 2012 | syntax:
C++ | size: 1.39 KB | hits: 19 | expires: Never
void CalculateSlopesUp()
{
for (int x = 0; x < GRID_SIZE; ++x)
{
for (int y = 0; y < GRID_SIZE; ++y)
{
int tileheight = gameTiles[x][y].GetHeight();
//no need for an upward slope if we are at max height
if (tileheight < 2)
{
bool IsSlopeAvailable = true;
//check if we are next to a sloped tile
if (AreSurroundingTilesSloped(x,y))
{
IsSlopeAvailable = false;
}
HexTile* TileUp = GetTileInDirection(x, y, UP);
if (TileUp)
{
if (TileUp->GetHeight() != tileheight + 1)
{
IsSlopeAvailable = false;
}
}
else
{
IsSlopeAvailable = false;
}
HexTile* TileUpLeft = GetTileInDirection(x, y, UPLEFT);
if (TileUpLeft)
{
if (TileUpLeft->GetHeight() <= tileheight)
{
IsSlopeAvailable = false;
}
}
HexTile* TileUpRight = GetTileInDirection(x, y, UPRIGHT);
if (TileUpRight)
{
if (TileUpRight->GetHeight() <= tileheight)
{
IsSlopeAvailable = false;
}
}
HexTile* TileDown = GetTileInDirection(x, y, DOWN);
if (TileDown)
{
if (TileDown->GetHeight() != tileheight)
{
IsSlopeAvailable = false;
}
}
else
{
IsSlopeAvailable = false;
}
if (IsSlopeAvailable)
{
gameTiles[x][y].SetSloped(UP);
}
}
}
}
}