From 12933729b942c3d452aef2c445a84778c3056668 Mon Sep 17 00:00:00 2001 From: Migdyn Date: Fri, 28 Oct 2022 23:47:09 -0400 Subject: [PATCH] Changes to mapblock --- include/Base.h | 3 ++- include/MapBlock.h | 7 ++++++- main.cpp | 18 +++++++++++++----- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/Base.h b/include/Base.h index 31e3d46..e2c807a 100644 --- a/include/Base.h +++ b/include/Base.h @@ -5,8 +5,9 @@ //#include "MapBlock.h" class NodeManager; +class BlockManager; extern NodeManager nodeManager; -extern NodeManager nodeManager1; +extern BlockManager blockManager; struct Position2D diff --git a/include/MapBlock.h b/include/MapBlock.h index a394186..d162067 100644 --- a/include/MapBlock.h +++ b/include/MapBlock.h @@ -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: }; diff --git a/main.cpp b/main.cpp index 4d37643..dddbc52 100644 --- a/main.cpp +++ b/main.cpp @@ -7,11 +7,13 @@ #include "TextureHandler.h" #include #include +#include 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);