Generator features.
This commit is contained in:
@@ -63,7 +63,7 @@ namespace CaveGame::Client
|
||||
|
||||
void Camera2D::Zoom(float val) {
|
||||
zoom = val;
|
||||
zoom = Math::Clamp(0.125f, zoom, 50.f);
|
||||
zoom = Math::Clamp(zoom, 0.125f, 50.f);
|
||||
}
|
||||
|
||||
void Camera2D::ZoomIn(float amt) {
|
||||
|
@@ -20,13 +20,29 @@ namespace CaveGame::Core
|
||||
static constexpr float HeightMapHighPassScale = 700.f;
|
||||
static constexpr float HeightMapLowPassAmplitude = 85.f;
|
||||
static constexpr float HeightMapLowPassScale = 64.f;
|
||||
static constexpr float TopSoilDepth = 225.f;
|
||||
static constexpr float TopSoilDepth = 345.f;
|
||||
|
||||
static constexpr float CaveInputScale = 800.f;
|
||||
static constexpr float CaveOutputScale = 1.25f;
|
||||
static constexpr float CaveErosionRange = 0.035f;
|
||||
static constexpr float CaveAdditiveInputScale = 80.f;
|
||||
static constexpr float CaveAdditiveOutputScale = 0.25f;
|
||||
static constexpr float SurfaceCaveShrinkDepth = 100;
|
||||
static constexpr float SurfaceCaveShrinkFactor = 2.f;
|
||||
|
||||
static constexpr float ClayVeinHiPassHScale = 200.f;
|
||||
static constexpr float ClayVeinHiPassVScale = 205.f;
|
||||
static constexpr float ClayVeinHiPassOffset = 0.f;
|
||||
static constexpr float ClayVeinHiPassOutputScale = 2.2f;
|
||||
|
||||
static constexpr float ClayVeinLoPassHScale = 17.f;
|
||||
static constexpr float ClayVeinLoPassVScale = 15.f;
|
||||
static constexpr float ClayVeinLoPassOffset = 420.f;
|
||||
static constexpr float ClayVeinLoPassOutputScale = 1.2f;
|
||||
|
||||
static constexpr float ClayVeinNoise = 0.175f;
|
||||
|
||||
static constexpr float ClayVeinRampFactor = 2.f;
|
||||
|
||||
public:
|
||||
Generator() = default;
|
||||
@@ -54,8 +70,10 @@ namespace CaveGame::Core
|
||||
return x % mod;
|
||||
}
|
||||
|
||||
/// Returns a value between 0 and 1.
|
||||
float GetPrecomputedWhiteNoise1D(int x) const;
|
||||
|
||||
/// Returns a value between 0 and 1.
|
||||
float GetPrecomputedWhiteNoise2D(int x, int y) const;
|
||||
|
||||
protected:
|
||||
|
@@ -9,6 +9,8 @@
|
||||
#include <Core/Interfaces.hpp>
|
||||
#include <J3ML/LinearAlgebra/Vector2i.hpp>
|
||||
|
||||
#include "Tile.hpp"
|
||||
|
||||
namespace CaveGame::Core
|
||||
{
|
||||
using J3ML::LinearAlgebra::Vector2i;
|
||||
@@ -203,6 +205,11 @@ namespace CaveGame::Core
|
||||
bool SpreadCheck(ITileMap* world, TileState state, int x, int y, TileID spreads_to) override;
|
||||
};
|
||||
|
||||
class SaplingTile : public Tile {
|
||||
public:
|
||||
|
||||
};
|
||||
|
||||
class GasTile : public Tile
|
||||
{
|
||||
|
||||
@@ -218,7 +225,6 @@ namespace CaveGame::Core
|
||||
using ID = Core::TileID;
|
||||
static const Tile Void {ID::VOID, "Void", Colors::Transparent};
|
||||
|
||||
|
||||
static const Tile Air {ID::AIR, "Air", Colors::Transparent};
|
||||
static const Tile Stone {ID::STONE, "Stone", Colors::Grays::SlateGray, {Colors::Grays::SlateGray, Colors::Grays::LightSlateGray}};
|
||||
static const Tile Dirt {ID::DIRT, "Dirt", Colors::Browns::Chocolate, {Colors::Browns::Chocolate, {210, 125, 30},{195, 105, 40}}};
|
||||
@@ -233,7 +239,7 @@ namespace CaveGame::Core
|
||||
static const Tile Granite {ID::GRANITE, "Granite", Colors::Whites::AntiqueWhite};
|
||||
static const Tile Marble {ID::MARBLE, "Marble", Colors::Whites::GhostWhite};
|
||||
static const GrassyTile Grass {ID::GRASS, "Grass", Colors::Greens::LawnGreen,
|
||||
{{126, 252, 5}, {124, 240, 0}, {124, 248, 8}}};
|
||||
{{126, 252, 5}, {122, 238, 0}, {124, 248, 12}}};
|
||||
static const GrassyTile GlowyGrass {ID::GLOWY_GRASS, "Glowy Grass", Colors::Blues::PowderBlue};
|
||||
|
||||
static const VineTile Vine {ID::VINE, "Vine", Colors::Greens::ForestGreen};
|
||||
@@ -250,8 +256,8 @@ namespace CaveGame::Core
|
||||
static const Tile BlackSandstone {ID::BLACK_SANDSTONE, "Black Sandstone", Colors::Black};
|
||||
|
||||
static const Tile Ash {ID::ASH, "Ash", Colors::Grays::DarkSlateGray};
|
||||
static const Tile Clay {ID::CLAY, "Clay", Colors::Browns::Brown};
|
||||
static const Tile Silt;
|
||||
static const Tile Clay {ID::CLAY, "Clay", Colors::Browns::Brown, {{164, 42, 42}, {164, 38, 42}, {172, 42, 52}, {164, 58, 62}}};
|
||||
static const Tile Silt {ID::SILT, "Silt", Colors::Browns::SaddleBrown};
|
||||
static const Tile Snow;
|
||||
static const Tile Ice;
|
||||
static const Tile Slush;
|
||||
@@ -366,4 +372,4 @@ namespace CaveGame::Core
|
||||
|
||||
void DefineTiles();
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -70,38 +70,80 @@ namespace CaveGame::Core
|
||||
return Core::AIR;
|
||||
} else { return base; }*/
|
||||
|
||||
|
||||
|
||||
|
||||
float cave_erosion = perlin.Noise(wx / CaveInputScale, wy / CaveInputScale, 0.f) * CaveOutputScale;
|
||||
|
||||
float cave_addition = perlin.Noise(wx / CaveAdditiveInputScale, wy / CaveAdditiveInputScale, 0.f)*CaveAdditiveOutputScale;
|
||||
cave_erosion += cave_addition;
|
||||
|
||||
// Make cave openings more narrow
|
||||
if (depth < 100) {
|
||||
cave_erosion *= 2.f;
|
||||
if (depth < SurfaceCaveShrinkDepth) {
|
||||
cave_erosion *= SurfaceCaveShrinkFactor;
|
||||
}
|
||||
|
||||
if (cave_erosion > -CaveErosionRange && CaveErosionRange > cave_erosion)
|
||||
{
|
||||
if (cave_erosion > -CaveErosionRange && CaveErosionRange > cave_erosion) {
|
||||
return TileID::AIR;
|
||||
} else {
|
||||
}
|
||||
|
||||
|
||||
if (depth > 1) {
|
||||
// Ore computation
|
||||
float ore_map_1 = perlin.Noise(wx / 50, wy / 50, 0.f) * 3.f;
|
||||
float ore_map_2 = perlin.Noise(wx / 500, wy / 500, 0.f) * 1.f;
|
||||
float clay_pass_1 = perlin.Noise(wx / ClayVeinHiPassHScale, wy / ClayVeinHiPassVScale, ClayVeinHiPassOffset) * ClayVeinHiPassOutputScale;
|
||||
float clay_pass_2 = perlin.Noise(wx / ClayVeinLoPassHScale, wy / ClayVeinLoPassVScale, ClayVeinLoPassOffset) * ClayVeinLoPassOutputScale;
|
||||
|
||||
float ore_map = ore_map_1 + ore_map_2;
|
||||
float rng = GetPrecomputedWhiteNoise2D(wx, wy)*0.175;
|
||||
|
||||
if (ore_map > 0.4f) {
|
||||
float clay_pass = clay_pass_1 + clay_pass_2 + ((clay_pass_1 * clay_pass_2) / 2.f) - rng;
|
||||
|
||||
if (clay_pass > 0.85f) {
|
||||
return TileID::CLAY;
|
||||
}
|
||||
|
||||
return base;
|
||||
if (clay_pass < -0.75f) {
|
||||
return TileID::DIRT;
|
||||
}
|
||||
|
||||
float silt_pass_1 = perlin.Noise(wx / 220.f, wy / 205.f, 5.f) * 2.2f;
|
||||
float silt_pass_2 = perlin.Noise(wx / 27.f, wy / 25.f, 422.f) * 1.25f;
|
||||
|
||||
//float rng = GetPrecomputedWhiteNoise2D(wx, wy)*0.175;
|
||||
|
||||
float silt_pass = silt_pass_1 + silt_pass_2 + ((silt_pass_1 * silt_pass_2) / 2.f) - rng;
|
||||
|
||||
if (silt_pass > 0.85f) {
|
||||
return TileID::SILT;
|
||||
}
|
||||
|
||||
if (silt_pass < -0.75f) {
|
||||
return TileID::DIRT;
|
||||
}
|
||||
|
||||
float stone_pass_1 = perlin.Noise(wx / 30.f, wy / 30.f, 666.f) * 2.4f;
|
||||
float stone_pass_2 = perlin.Noise(wx / 220.f, wy / 220.f, 0.5f) * 1.75f;
|
||||
|
||||
float stone_pass = stone_pass_1 + stone_pass_2 + (stone_pass_1 * stone_pass_2 / 1.75f) + (rng*1.5f);
|
||||
|
||||
// Chunks of stone
|
||||
if (stone_pass > 0.7f) {
|
||||
return TileID::STONE;
|
||||
}
|
||||
if (stone_pass < -0.7f) {
|
||||
return TileID::STONE;
|
||||
}
|
||||
|
||||
//float dirt_pass_1 = perlin.Noise(wx / 30.f, wy / 30.f, 12.f) * 1.35f;
|
||||
//float dirt_pass_2 = perlin.Noise(wx / 90.f, wy / 90.f, 0.5f) * 0.75f;
|
||||
|
||||
//float dirt_pass = dirt_pass_1 + dirt_pass_2;
|
||||
|
||||
// Chunks of dirt
|
||||
//if (-0.65 > dirt_pass && dirt_pass < 0.65f) {
|
||||
//return TileID::DIRT;
|
||||
//}
|
||||
|
||||
// Chunks of clay
|
||||
}
|
||||
|
||||
|
||||
return base;
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user