diff --git a/LevelGenerator.cpp b/LevelGenerator.cpp new file mode 100644 index 0000000..c8084b8 --- /dev/null +++ b/LevelGenerator.cpp @@ -0,0 +1,43 @@ +#include "LevelGenerator.h" + +FastNoiseLite perlin, os, cellular; +int seed = 138; + +perlin.SetSeed(seed); +perlin.SetNoiseType(FastNoiseLite::NoiseType_Perlin); +perlin.SetFrequency(.01F); + +os.SetSeed(seed); +os.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2); +os.SetFrequency(.01F); + +cellular.SetSeed(seed); +cellular.SetNoiseType(FastNoiseLite::NoiseType_Cellular); +cellular.SetFrequency(.1F); + +LevelGenerator::LevelGenerator() +{ + +} + +void LevelGenerator::generateBlock() +{ + for(int bx = 0; bx < 8; bx++) + { + for(int bz = 0; bz < 8; bz++) + { + for(int x = 0; x < 16; x++) + { + for(int z = 0; z < 16; z++) + { + float cX = (float)x + (16 * bx); + float cZ = (float)z + (16 * bz); + for(int y = 0; y < 48 * abs(perlin.GetNoise(cX, cZ)) / 2 + abs(cellular.GetNoise(cX, cZ)) * 2 + abs(os.GetNoise(cX, cZ)) * 4 + 10; y++) + { + blockManager.mapBlocks[bx][bz].addNode(y > 20 ? 1 : 2, 0, x, y, z); + } + } + } + } + } +} diff --git a/XtreemNodes.cbp b/XtreemNodes.cbp index 7678d56..1f7feae 100644 --- a/XtreemNodes.cbp +++ b/XtreemNodes.cbp @@ -40,12 +40,15 @@ + + + diff --git a/XtreemNodes.depend b/XtreemNodes.depend index 26a9616..c6795c3 100644 --- a/XtreemNodes.depend +++ b/XtreemNodes.depend @@ -1,5 +1,5 @@ # depslib dependency file v1.0 -1667337375 source:c:\development\xtreemminer\main.cpp +1672097148 source:c:\development\xtreemminer\main.cpp "Utilities.h" @@ -9,31 +9,30 @@ "TextureHandler.h" - "FastNoiseLite.h" -1667164197 c:\development\xtreemminer\include\noderenderer.h +1667160597 c:\development\xtreemminer\include\noderenderer.h "Base.h" "MapBlock.h" -1667167677 c:\development\xtreemminer\include\mapblock.h +1667164077 c:\development\xtreemminer\include\mapblock.h "Base.h" -1667069440 c:\development\xtreemminer\include\base.h +1667065840 c:\development\xtreemminer\include\base.h 1666531672 source:c:\development\xtreemminer\base.cpp "MapBlock.h" "Base.h" -1667148859 c:\development\xtreemminer\include\texturehandler.h +1672105046 c:\development\xtreemminer\include\texturehandler.h "stb_image.h" "Base.h" -1666448933 c:\development\xtreemminer\include\stb_image.h +1666445333 c:\development\xtreemminer\include\stb_image.h "stb_image.h" @@ -50,12 +49,12 @@ -1667069440 c:\development\xtreemminer\include\utilities.h +1667065840 c:\development\xtreemminer\include\utilities.h 1667079584 c:\development\xtreemminer\include\fastnoiselite.h -1667167831 source:c:\development\xtreemminer\mapblock.cpp +1667350805 source:c:\development\xtreemminer\mapblock.cpp "MapBlock.h" 1667294728 source:/home/kacperks/projects/XtreemNodes/MapBlock.cpp @@ -113,10 +112,10 @@ 1667294728 /home/kacperks/projects/XtreemNodes/include/FastNoiseLite.h -1667351497 source:c:\development\xtreemminer\gui.cpp +1667347897 source:c:\development\xtreemminer\gui.cpp "GUI.h" -1667336637 c:\development\xtreemminer\include\gui.h +1667333037 c:\development\xtreemminer\include\gui.h "Base.h" diff --git a/XtreemNodes.layout b/XtreemNodes.layout index 862f813..9c6732e 100644 --- a/XtreemNodes.layout +++ b/XtreemNodes.layout @@ -2,52 +2,72 @@ - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/img/apple.png b/data/img/apple.png deleted file mode 100644 index 750557e..0000000 Binary files a/data/img/apple.png and /dev/null differ diff --git a/data/img/cobble.png b/data/img/cobble.png deleted file mode 100644 index 0faee33..0000000 Binary files a/data/img/cobble.png and /dev/null differ diff --git a/data/img/gold.png b/data/img/gold.png deleted file mode 100644 index ca5853b..0000000 Binary files a/data/img/gold.png and /dev/null differ diff --git a/data/img/grass.png b/data/img/grass.png deleted file mode 100644 index 84f83a2..0000000 Binary files a/data/img/grass.png and /dev/null differ diff --git a/data/img/grass_side.png b/data/img/grass_side.png deleted file mode 100644 index 453c64d..0000000 Binary files a/data/img/grass_side.png and /dev/null differ diff --git a/data/img/iron.png b/data/img/iron.png deleted file mode 100644 index e3e6e84..0000000 Binary files a/data/img/iron.png and /dev/null differ diff --git a/data/img/maple.png b/data/img/maple.png deleted file mode 100644 index f6c6f9d..0000000 Binary files a/data/img/maple.png and /dev/null differ diff --git a/data/img/oak.png b/data/img/oak.png deleted file mode 100644 index 76da003..0000000 Binary files a/data/img/oak.png and /dev/null differ diff --git a/data/img/test.png b/data/img/test.png deleted file mode 100644 index 8ace58b..0000000 Binary files a/data/img/test.png and /dev/null differ diff --git a/data/img/texturemap.png b/data/img/texturemap.png new file mode 100644 index 0000000..b9facd7 Binary files /dev/null and b/data/img/texturemap.png differ diff --git a/include/LevelGenerator.h b/include/LevelGenerator.h new file mode 100644 index 0000000..8f64374 --- /dev/null +++ b/include/LevelGenerator.h @@ -0,0 +1,18 @@ +#ifndef LEVELGENERATOR +#define LEVELGENERATOR +#include "FastNoiseLite.h" + +class LevelGenerator +{ + public: + LevelGenerator(); + void generateBlock(); + + protected: + + private: + FastNoiseLite perlin, os, cellular; + int seed = 138; +}; + +#endif diff --git a/include/TextureHandler.h b/include/TextureHandler.h index 5fd4572..4a8b059 100644 --- a/include/TextureHandler.h +++ b/include/TextureHandler.h @@ -26,7 +26,7 @@ class TextureHandler void loadAllTextures() { int textureIndex = 0; - imageData = loadTexture("data/img/grass.png"); + imageData = loadTexture("data/img/texturemap.png"); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); diff --git a/main.cpp b/main.cpp index 5755306..37de996 100644 --- a/main.cpp +++ b/main.cpp @@ -7,12 +7,10 @@ #include "TextureHandler.h" #include #include -#include "FastNoiseLite.h" #include #include NodeRenderer renderer; -//BlockManager blockManager; BlockManager blockManager; TextureHandler textureHandler; @@ -163,38 +161,9 @@ int main(int argc, char **argv) // Load textures textureHandler.loadAllTextures(); - FastNoiseLite perlin, os, cellular; - int seed = 138; - perlin.SetSeed(seed); - perlin.SetNoiseType(FastNoiseLite::NoiseType_Perlin); - perlin.SetFrequency(.01F); - os.SetSeed(seed); - os.SetNoiseType(FastNoiseLite::NoiseType_OpenSimplex2); - os.SetFrequency(.01F); - cellular.SetSeed(seed); - cellular.SetNoiseType(FastNoiseLite::NoiseType_Cellular); - cellular.SetFrequency(.1F); - for(int bx = 0; bx < 8; bx++) - { - for(int bz = 0; bz < 8; bz++) - { - for(int x = 0; x < 16; x++) - { - for(int z = 0; z < 16; z++) - { - float cX = (float)x + (16 * bx); - float cZ = (float)z + (16 * bz); - for(int y = 0; y < 48 * abs(perlin.GetNoise(cX, cZ)) / 2 + abs(cellular.GetNoise(cX, cZ)) * 2 + abs(os.GetNoise(cX, cZ)) * 4 + 10; y++) - { - blockManager.mapBlocks[bx][bz].addNode(y > 20 ? 1 : 2, 0, x, y, z); - } - } - } - } - }