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

@@ -14,14 +14,13 @@
NodeRenderer renderer;
//BlockManager blockManager;
NodeManager nodeManager;
NodeManager nodeManager1;
BlockManager blockManager;
TextureHandler textureHandler;
GLfloat playerX = 0;
GLfloat playerY = 30;
GLfloat playerZ = 100;
GLfloat playerY = -30;
GLfloat playerZ = -100;
GLfloat playerRotX = 0;
GLfloat playerRotY = 0;
@@ -32,12 +31,13 @@ void display()
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(-playerX, -playerY, -playerZ);
glRotatef(playerRotX, 1.0F, .0F, .0F);
glRotatef(playerRotY, .0F, 1.0F, .0F);
glTranslatef(playerX, playerY, playerZ);
//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glBegin(GL_QUADS);
@@ -73,7 +73,7 @@ void display()
const sf::Window& window = nullptr;
sf::Vector2i mouseDelta = sf::Mouse::getPosition(window) - lastMousePos;
lastMousePos = sf::Mouse::getPosition(window);*/
glutPostRedisplay();
//glutPostRedisplay();
}
@@ -90,9 +90,10 @@ void reshape(int width, int height)
glutPostRedisplay();
}
void updateTimer()
void updateTimer(int time)
{
//glutTimerFunc(30, &updateTimer, 0);
glutPostRedisplay();
glutTimerFunc(30, &updateTimer, 0);
}
void KeyboardFunc(unsigned char key, int x, int y)
@@ -109,24 +110,22 @@ void KeyboardFunc(unsigned char key, int x, int y)
if(key == 'w')
{
playerX += .8;
playerZ += .8;
}
if(key == 's')
{
playerX -= sin(Utilities::degToRad(playerRotY));
playerY += sin(Utilities::degToRad(playerRotX));
playerZ += cos(Utilities::degToRad(playerRotY));
playerZ -= .8;
}
if(key == 'q')
{
playerY += .1F;
playerY += .8F;
}
if(key == 'e')
{
playerY -= .1F;
playerY -= .8F;
}
if(key == 't')
@@ -175,7 +174,10 @@ int main(int argc, char **argv)
glClearColor(.2, .7, .8 , 255);
glEnable(GL_DEPTH_TEST);
glEnable(GL_TEXTURE_2D);
/*glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
glFrontFace(GL_CCW);*/
// Load textures
textureHandler.loadAllTextures();
@@ -183,12 +185,12 @@ int main(int argc, char **argv)
FastNoiseLite fnl;
fnl.SetSeed(1337);
fnl.SetNoiseType(FastNoiseLite::NoiseType_Value);
fnl.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2);
fnl.SetFrequency(.01F);
for(int bx = 0; bx < 8; bx++)
for(int bx = 0; bx < 16; bx++)
{
for(int bz = 0; bz < 8; bz++)
for(int bz = 0; bz < 16; bz++)
{
for(int x = 0; x < 16; x++)
{
@@ -196,7 +198,7 @@ int main(int argc, char **argv)
{
for(int y = 0; y < 48 * abs(fnl.GetNoise((float)x + (16 * bx), (float)z + (16 * bz))) + 2; y++)
{
blockManager.mapBlocks[bx][bz].addNode(1, 0, x, y, z);
blockManager.mapBlocks[bx][bz].addNode(y > 30 ? 1 : 2, 0, x, y, z);
}
}
}
@@ -225,7 +227,7 @@ int main(int argc, char **argv)
updateTimer();
updateTimer(0);
glutDisplayFunc(&display);
glutReshapeFunc(&reshape);
glutKeyboardFunc(&KeyboardFunc);