From f71cb8a968ba5b284d960d89642c1c62fc9d6f4f Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Thu, 26 Apr 2018 18:32:35 +0200 Subject: Redo the world generation. --- src/game/worldgen.cpp | 73 ++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 33 deletions(-) diff --git a/src/game/worldgen.cpp b/src/game/worldgen.cpp index 12bd3b1..d1dd8ad 100644 --- a/src/game/worldgen.cpp +++ b/src/game/worldgen.cpp @@ -95,11 +95,11 @@ just_decos: break; case TILE_GRAVEL: - if (noise > 0.26) + if (noise > 0.25) type = DECO_CRYSTAL; - else if (noise > 0.25) + else if (noise > 0.21) type = DECO_STONE; - else if (noise > 0.13) + else if (noise > 0.12) type = DECO_STONE_SMALL; else return; @@ -128,45 +128,52 @@ void worldgen(world_t *world, sector_index_t index, sector_t *sector, tile_index_t tile_index(index[0] * SECTOR_SIZE + lx, index[1] * SECTOR_SIZE + ly); v2f_t x; - float biome, waterlevel, height; + float waterlevel, height, biome; x = v2f_t(index) * SECTOR_SIZE + v2f_t(lx, ly); waterlevel = world->perlin.get(x, 1000.0f) * 0.3f + - world->perlin.get(x, 500.0f) * 0.1f; + world->perlin.get(x, 500.0f) * 0.1f; - biome = world->perlin.get(-x + v2f_t(-60, 120), 160.0f) * 0.4f + - world->perlin.get(x, 30.0f) * 0.2f + - world->perlin.get(x, 8.0f) * 0.03f; + height = world->perlin.get(x, 40.0f) * 0.6f + + world->perlin.get(x, 20.0f) * 0.25f + + world->perlin.get(x, 10.0f) * 0.2f + + world->perlin.get(x, 4.0f) * 0.1f + + world->perlin.get(x, 1.0f) * 0.05f; + if (height > waterlevel + 0.12f) { + float noise1, noise2; - height = world->perlin.get(x, 40.0f) * 0.6f + - world->perlin.get(x, 20.0f) * 0.25f + - world->perlin.get(x, 10.0f) * 0.2f + - world->perlin.get(x, 4.0f) * 0.1f + - world->perlin.get(x, 1.0f) * 0.05f; - - if (biome < 0.0f) { - if (height < waterlevel) - tile->type = TILE_WATER; - else if (height < waterlevel + 0.12) - tile->type = TILE_DIRT; - else if (world->perlin.get(x, 4.0f) > 0.0f) - tile->type = TILE_STONE; - else - tile->type = TILE_DIRT; - } else if (biome < 0.1f) { - if (height < waterlevel - 0.07f) - tile->type = TILE_STONE; - else + noise1 = world->perlin.get(x, 2.6f) + + world->perlin.get(x, 7.0f); + + noise2 = world->perlin.get(x, 10.0f); + + if (height > waterlevel + 0.18f + noise1 * 0.16f || + noise2 > 0.3f) tile->type = TILE_GRAVEL; - } else { - if (height < waterlevel) - tile->type = TILE_DIRT_RED; - else if (world->perlin.get(x, 3.0f) > 0.0f) - tile->type = TILE_STONE_RED; else - tile->type = TILE_DIRT_RED; + tile->type = TILE_STONE; + + } else if (height > waterlevel) + tile->type = TILE_DIRT; + else + tile->type = TILE_WATER; + + biome = world->perlin.get(x, 60.0f) * 0.6f + + world->perlin.get(x, 30.0f) * 0.25f + + world->perlin.get(x, 15.0f) * 0.2f + + world->perlin.get(x, 7.0f) * 0.1f + + world->perlin.get(x, 3.0f) * 0.05f; + + if (biome > 0.2f) switch (tile->type) { + case TILE_DIRT: + tile->type = TILE_DIRT_RED; + break; + + case TILE_STONE: + tile->type = TILE_STONE_RED; + break; } } -- cgit