XtreemNodes/LevelGenerator.cpp

44 lines
1.1 KiB
C++

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