Changes to mapblock

This commit is contained in:
Functioning Member of Society 2022-10-28 23:47:09 -04:00
parent 1a26c07604
commit 12933729b9
3 changed files with 21 additions and 7 deletions

View File

@ -5,8 +5,9 @@
//#include "MapBlock.h"
class NodeManager;
class BlockManager;
extern NodeManager nodeManager;
extern NodeManager nodeManager1;
extern BlockManager blockManager;
struct Position2D

View File

@ -13,7 +13,7 @@ class NodeManager
int blockX;
int blockZ;
NodeManager(int x, int z)
NodeManager()
{
@ -50,6 +50,11 @@ class BlockManager
public:
NodeManager mapBlocks[8][8]; // 8 x 8 blocks
BlockManager()
{
}
private:
};

View File

@ -7,11 +7,13 @@
#include "TextureHandler.h"
#include <cstdio>
#include <random>
#include <SFML/System.hpp>
NodeRenderer renderer;
//BlockManager blockManager;
NodeManager nodeManager(0, 0);
NodeManager nodeManager1(1, 0);
NodeManager nodeManager;
NodeManager nodeManager1;
BlockManager blockManager;
TextureHandler textureHandler;
GLfloat playerX = 0;
@ -86,6 +88,11 @@ void reshape(int width, int height)
glutPostRedisplay();
}
void updateTimer()
{
//glutTimerFunc(30, &updateTimer, 0);
}
void KeyboardFunc(unsigned char key, int x, int y)
{
if(key == 'a')
@ -144,6 +151,7 @@ void KeyboardFunc(unsigned char key, int x, int y)
int main(int argc, char **argv)
{
glutInit(&argc, argv);
@ -167,7 +175,7 @@ int main(int argc, char **argv)
{
for(int y = 0; y < 256; y++)
{
nodeManager.addNode(rand() % 3, 0, x, y, z);
blockManager.mapBlocks[0][0].addNode(rand() % 3, 0, x, y, z);
//printf("\nGet node at: %i\n Is air: %i", nodeManager.getNodeAt(x, y + 1, z) == 0, nodeManager.isAir(x, y + 1, z));
}
}
@ -179,13 +187,13 @@ int main(int argc, char **argv)
{
for(int y = 0; y < 256; y++)
{
nodeManager1.addNode(rand() % 3, 0, x, y, z);
blockManager.mapBlocks[1][0].addNode(rand() % 3, 0, x, y, z);
//printf("\nGet node at: %i\n Is air: %i", nodeManager.getNodeAt(x, y + 1, z) == 0, nodeManager.isAir(x, y + 1, z));
}
}
}
updateTimer();
glutDisplayFunc(&display);
glutReshapeFunc(&reshape);
glutKeyboardFunc(&KeyboardFunc);