This commit is contained in:
{{QWERTYKBGUI}} 2023-02-25 16:06:29 -05:00
commit c3fa504c29
15 changed files with 200 additions and 38 deletions

43
LevelGenerator.cpp Normal file
View File

@ -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);
}
}
}
}
}
}

View File

@ -1,5 +1,9 @@
# depslib dependency file v1.0
<<<<<<< HEAD
1672107417 source:c:\development\xtreemminer\main.cpp
=======
1672097148 source:c:\development\xtreemminer\main.cpp
>>>>>>> dcac2713f6b72f4d2252632a179b30a33fd827a8
<stdlib.h>
<GL/glut.h>
"Utilities.h"
@ -9,11 +13,14 @@
"TextureHandler.h"
<math.h>
<cstdio>
"FastNoiseLite.h"
<random>
<SFML/Window.hpp>
<<<<<<< HEAD
1672201712 c:\development\xtreemminer\include\noderenderer.h
=======
1667160597 c:\development\xtreemminer\include\noderenderer.h
>>>>>>> dcac2713f6b72f4d2252632a179b30a33fd827a8
"Base.h"
"MapBlock.h"
<GL/glut.h>
@ -29,7 +36,11 @@
"MapBlock.h"
"Base.h"
<<<<<<< HEAD
1672341127 c:\development\xtreemminer\include\texturehandler.h
=======
1672105046 c:\development\xtreemminer\include\texturehandler.h
>>>>>>> dcac2713f6b72f4d2252632a179b30a33fd827a8
"stb_image.h"
"Base.h"

View File

@ -2,16 +2,23 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<<<<<<< HEAD
<File name="include\FastNoiseLite.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="100664" topLine="2262" />
</Cursor>
</File>
<File name="include\Base.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
=======
<File name="include\NodeRenderer.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor>
<Cursor1 position="28" topLine="0" />
<Cursor1 position="2409" topLine="24" />
>>>>>>> dcac2713f6b72f4d2252632a179b30a33fd827a8
</Cursor>
</File>
<File name="MapBlock.cpp" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="29" topLine="0" />
</Cursor>
</File>
<<<<<<< HEAD
<File name="include\MapBlock.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="438" topLine="0" />
@ -33,16 +40,68 @@
</Cursor>
</File>
<File name="include\Nodes.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
=======
<File name="include\Nodes.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
>>>>>>> dcac2713f6b72f4d2252632a179b30a33fd827a8
<Cursor>
<Cursor1 position="264" topLine="0" />
</Cursor>
</File>
<<<<<<< HEAD
<File name="include\Logger.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
=======
<File name="include\LevelGenerator.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="174" topLine="0" />
</Cursor>
</File>
<File name="GUI.cpp" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1286" topLine="3" />
</Cursor>
</File>
<File name="include\stb_image.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="8925" topLine="160" />
</Cursor>
</File>
<File name="LevelGenerator.cpp" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="87" topLine="0" />
</Cursor>
</File>
<File name="include\FastNoiseLite.h" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
>>>>>>> dcac2713f6b72f4d2252632a179b30a33fd827a8
<Cursor>
<Cursor1 position="97" topLine="0" />
</Cursor>
</File>
<File name="include\TextureHandler.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="include\Base.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="28" topLine="0" />
</Cursor>
</File>
<File name="include\MapBlock.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="438" topLine="3" />
</Cursor>
</File>
<File name="include\Logger.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="97" topLine="0" />
</Cursor>
</File>
<File name="include\GUI.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="331" topLine="0" />
</Cursor>
</File>
<File name="main.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="201" topLine="0" />
</Cursor>
</File>
<File name="include\TextureHandler.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="16" />
</Cursor>

59
XtreemNodesLinux.cbp Normal file
View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="XtreemNodes" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/XtreemNodes" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
<Add directory="include" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/XtreemNodes" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
<Add directory="include" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Linker>
<Add option="-lGLEW" />
<Add option="-lGL" />
<Add option="-lsfml" />
</Linker>
<Unit filename="GUI.cpp" />
<Unit filename="MapBlock.cpp" />
<Unit filename="include/Base.h" />
<Unit filename="include/FastNoiseLite.h" />
<Unit filename="include/GUI.h" />
<Unit filename="include/Logger.h" />
<Unit filename="include/MapBlock.h" />
<Unit filename="include/NodeRenderer.h" />
<Unit filename="include/Nodes.h" />
<Unit filename="include/TextureHandler.h" />
<Unit filename="include/Utilities.h" />
<Unit filename="include/stb_image.h" />
<Unit filename="main.cpp" />
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>

View File

@ -40,12 +40,15 @@
<Add option="-lglu32" />
<Add option="-lopengl32" />
<Add option="-lsfml-window" />
<Add option="-lsfml-graphics" />
</Linker>
<Unit filename="GUI.cpp" />
<Unit filename="LevelGenerator.cpp" />
<Unit filename="MapBlock.cpp" />
<Unit filename="include/Base.h" />
<Unit filename="include/FastNoiseLite.h" />
<Unit filename="include/GUI.h" />
<Unit filename="include/LevelGenerator.h" />
<Unit filename="include/Logger.h" />
<Unit filename="include/MapBlock.h" />
<Unit filename="include/NodeRenderer.h" />

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 857 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 289 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 347 B

BIN
data/img/texturemap.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

18
include/LevelGenerator.h Normal file
View File

@ -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

View File

@ -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);

View File

@ -7,12 +7,10 @@
#include "TextureHandler.h"
#include <math.h>
#include <cstdio>
#include "FastNoiseLite.h"
#include <random>
#include <SFML/Window.hpp>
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);
}
}
}
}
}