Minor changes

This commit is contained in:
2022-10-30 11:53:41 -04:00
parent 1965b97c19
commit 922826da0b
6 changed files with 45 additions and 47 deletions

View File

@@ -7,22 +7,18 @@
class NodeManager
class MapBlock
{
public:
int blockX;
int blockZ;
NodeManager()
MapBlock()
{
}
virtual ~NodeManager()
{
}
void addNode(int id, int meta, int x, int y, int z)
{
@@ -36,7 +32,7 @@ class NodeManager
int getNodeAt(int x, int y, int z)
{
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 0;
return x < 16 && z < 16 && x >= 0 && z >= 0 ? mapBlock[256 * y + z * 16 + x] : 1;
}
protected:
@@ -48,7 +44,7 @@ class NodeManager
class BlockManager
{
public:
NodeManager mapBlocks[8][8]; // 8 x 8 blocks
MapBlock mapBlocks[16][16]; // 8 x 8 blocks
BlockManager()
{

View File

@@ -21,6 +21,7 @@ class NodeRenderer
{
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z); // The block the node at (x, y, z) is in
glColor3f(1.0F, 1.0F, 1.0F);
glBegin(GL_QUADS);
// Front
@@ -35,10 +36,13 @@ class NodeRenderer
glTexCoord2f(1.0F, 1.0F);
glVertex3f(x + 1.0F, y + .0F, z + .0F);
//glColor3f(.0F, .0F, .8F);
glTexCoord2f(.0F, 1.0F);
glVertex3f(x + .0F, y + .0F, z + .0F);
}
glColor3f(1.0F, 1.0F, 1.0F);
// Back
if(blockManager.mapBlocks[block.x][block.z].isAir(x - block.x * 16, y, z - block.z * 16 + 1))
{

View File

@@ -39,7 +39,7 @@ class TextureHandler
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, imageData);
imageData1 = loadTexture("data/img/iron.png");
imageData1 = loadTexture("data/img/oak.png");
glGenTextures(1, &textures1);
glBindTexture(GL_TEXTURE_2D, textures1);
@@ -52,17 +52,16 @@ class TextureHandler
void getTextureForNode(int x, int y, int z)
{
//if(nodeManager.getNodeAt(x, y, z) == 1)
//{
Position2D block = BlockUtilities::getBlockFromNodeCoordinates(x, z);
if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16) == 1)
{
glBindTexture(GL_TEXTURE_2D, textures);
//}
}
//else if(nodeManager.getNodeAt(x, y, z) == 2)
//{
//glBindTexture(GL_TEXTURE_2D, textures1);
//}
else if(blockManager.mapBlocks[block.x][block.z].getNodeAt(x - block.x * 16, y, z - block.z * 16) == 2)
{
glBindTexture(GL_TEXTURE_2D, textures1);
}
}