Simplified the code for checking nodes and added simple shading

This commit is contained in:
2022-10-30 12:56:14 -04:00
parent 1d1aad04cf
commit 4c76fd1144
5 changed files with 79 additions and 55 deletions

View File

@@ -10,8 +10,7 @@
class MapBlock
{
public:
int blockX;
int blockZ;
int mapBlock[65536];
MapBlock()
{
@@ -25,33 +24,6 @@ class MapBlock
mapBlock[256 * y + z * 16 + x] = id;
}
bool isAir(int x, int y, int z)
{
return getNodeAt(x, y, z) == 0;
}
int getNodeAt(int x, int y, int z)
{
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 1;
}
protected:
private:
int mapBlock[65536];
};
class BlockManager
{
public:
MapBlock mapBlocks[16][16]; // 8 x 8 blocks
BlockManager()
{
}
private:
};
@@ -70,10 +42,42 @@ class BlockUtilities
pos2d.z = floor(z / 16);
return pos2d;
}
};
class BlockManager
{
public:
MapBlock mapBlocks[16][16]; // 16 x 16 blocks
BlockManager()
{
}
int getNodeAt(int x, int y, int z)
{
//if(x < 16 && x >= 0 && z < 16 && z >= 0)
//{
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
return mapBlocks[block.x][block.z].mapBlock[256 * y + z * 16 + x];
// else
// {
//return mapBlocks[BlockUtilities::getBlockFromNodeCoordinates(x, z).x][BlockUtilities::getBlockFromNodeCoordinates(x, z).z];
//return 0;
//}
}
bool isAir(int x, int y, int z)
{
return getNodeAt(x, y, z) == 0;
}
private:
};
#endif