From b931bbd9a67c4519616bbd1ba4dc978dc620f8b3 Mon Sep 17 00:00:00 2001 From: Bluepr1nt Date: Tue, 26 Apr 2016 11:21:55 +0200 Subject: [PATCH] world tree fix --- OpenGL2/Main.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/OpenGL2/Main.cpp b/OpenGL2/Main.cpp index 02e0d48..f2c3ce3 100644 --- a/OpenGL2/Main.cpp +++ b/OpenGL2/Main.cpp @@ -11,6 +11,8 @@ #define STB_PERLIN_IMPLEMENTATION #include "stb_perlin.h" +void drawTree(int, int, int, int); + float lastFrameTime = 0; float speed = 10; @@ -58,10 +60,10 @@ void generateWorld() { for (int y = 0; y < worldHeight; y++) { if (y < worldHeight / 2) - world[x][z][y] = Block{ 1, 1}; + world[x][z][y] = Block{ 1, 1 }; else if (y < (heightInt + worldHeight / 2)) world[x][z][y] = Block{ 2, 2 }; - else if (y == (heightInt + worldHeight/2)) + else if (y == (heightInt + worldHeight / 2)) world[x][z][y] = Block{ 0, 3 }; else world[x][z][y] = Block{ -1, -1 }; @@ -150,7 +152,8 @@ void drawTree(int xlocation, int ylocation, int zlocation, int height) for (int z = zlocation; z <= zlocation+height; z += blockSize) { glPushMatrix(); - glTranslatef((float)xlocation, (float)z, (float)ylocation); + world[xlocation][z][ylocation] = Block{ 21, 20 }; + //glTranslatef((float)xlocation, (float)z, (float)ylocation); drawCube(21, 20); glPopMatrix(); } @@ -162,8 +165,9 @@ void drawTree(int xlocation, int ylocation, int zlocation, int height) for (int z = zlocation + height -(height/3); z <= zlocation + height+(height / 3); z += blockSize) { glPushMatrix(); - glTranslatef((float)x, (float)z, (float)y); - drawCube(53); + world[x][z][y] = Block{ 0, 53 }; + //glTranslatef((float)x, (float)z, (float)y); + //drawCube(53); glPopMatrix(); } }