From a6a38717c5a4d14778c988d9f29244cbf9faf049 Mon Sep 17 00:00:00 2001 From: Kenneth van Ewijk Date: Tue, 26 Apr 2016 10:32:16 +0200 Subject: [PATCH] Tried fixing heigth generating --- OpenGL2/Main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/OpenGL2/Main.cpp b/OpenGL2/Main.cpp index f2a1d2d..b343b2b 100644 --- a/OpenGL2/Main.cpp +++ b/OpenGL2/Main.cpp @@ -46,14 +46,17 @@ void generateWorld() { { for (int z = 0; z < worldDepth; z++) { - int heigth = (int)(stb_perlin_noise3(100, 100, 100) * 10); - std::cout << height << std::endl; + float heigth = stb_perlin_noise3((1.0f/(float)worldWidth)*(float)x, (1.0f / (float)worldDepth)*(float)z, 0); + int heightInt = (int)(height * 8); + std::cout << height << " - " << heightInt << std::endl; for (int y = 0; y < worldHeight; y++) { if (y < worldHeight / 2) world[x][z][y] = Block{ 1, 1}; - else if (y < height) + else if (y < (heightInt + worldHeight / 2)) + world[x][z][y] = Block{ 2, 2 }; + else if (y == (heightInt + worldHeight/2)) world[x][z][y] = Block{ 0, 3 }; else world[x][z][y] = Block{ -1, -1 };