Changes to mapblock
This commit is contained in:
parent
1a26c07604
commit
12933729b9
@ -5,8 +5,9 @@
|
|||||||
//#include "MapBlock.h"
|
//#include "MapBlock.h"
|
||||||
|
|
||||||
class NodeManager;
|
class NodeManager;
|
||||||
|
class BlockManager;
|
||||||
extern NodeManager nodeManager;
|
extern NodeManager nodeManager;
|
||||||
extern NodeManager nodeManager1;
|
extern BlockManager blockManager;
|
||||||
|
|
||||||
|
|
||||||
struct Position2D
|
struct Position2D
|
||||||
|
@ -13,7 +13,7 @@ class NodeManager
|
|||||||
int blockX;
|
int blockX;
|
||||||
int blockZ;
|
int blockZ;
|
||||||
|
|
||||||
NodeManager(int x, int z)
|
NodeManager()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
@ -50,6 +50,11 @@ class BlockManager
|
|||||||
public:
|
public:
|
||||||
NodeManager mapBlocks[8][8]; // 8 x 8 blocks
|
NodeManager mapBlocks[8][8]; // 8 x 8 blocks
|
||||||
|
|
||||||
|
BlockManager()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
18
main.cpp
18
main.cpp
@ -7,11 +7,13 @@
|
|||||||
#include "TextureHandler.h"
|
#include "TextureHandler.h"
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <random>
|
#include <random>
|
||||||
|
#include <SFML/System.hpp>
|
||||||
|
|
||||||
NodeRenderer renderer;
|
NodeRenderer renderer;
|
||||||
//BlockManager blockManager;
|
//BlockManager blockManager;
|
||||||
NodeManager nodeManager(0, 0);
|
NodeManager nodeManager;
|
||||||
NodeManager nodeManager1(1, 0);
|
NodeManager nodeManager1;
|
||||||
|
BlockManager blockManager;
|
||||||
TextureHandler textureHandler;
|
TextureHandler textureHandler;
|
||||||
|
|
||||||
GLfloat playerX = 0;
|
GLfloat playerX = 0;
|
||||||
@ -86,6 +88,11 @@ void reshape(int width, int height)
|
|||||||
glutPostRedisplay();
|
glutPostRedisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateTimer()
|
||||||
|
{
|
||||||
|
//glutTimerFunc(30, &updateTimer, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void KeyboardFunc(unsigned char key, int x, int y)
|
void KeyboardFunc(unsigned char key, int x, int y)
|
||||||
{
|
{
|
||||||
if(key == 'a')
|
if(key == 'a')
|
||||||
@ -144,6 +151,7 @@ void KeyboardFunc(unsigned char key, int x, int y)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
glutInit(&argc, argv);
|
glutInit(&argc, argv);
|
||||||
@ -167,7 +175,7 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
for(int y = 0; y < 256; y++)
|
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));
|
//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++)
|
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));
|
//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);
|
glutDisplayFunc(&display);
|
||||||
glutReshapeFunc(&reshape);
|
glutReshapeFunc(&reshape);
|
||||||
glutKeyboardFunc(&KeyboardFunc);
|
glutKeyboardFunc(&KeyboardFunc);
|
||||||
|
Loading…
Reference in New Issue
Block a user