summaryrefslogtreecommitdiff
path: root/src/game/worldgen.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-12-12 15:44:19 +0100
committerPaweł Redman <pawel.redman@gmail.com>2017-12-12 15:44:19 +0100
commitc33d0fa9c43fb316a9c6bbb2be81446dce7f49da (patch)
treea4ded215d9dd7c5098b395925f0c19956c46670c /src/game/worldgen.cpp
parent5667984053536d855ba0917deac326d429f2c5b4 (diff)
Move tile data to src/game.
Diffstat (limited to 'src/game/worldgen.cpp')
-rw-r--r--src/game/worldgen.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/game/worldgen.cpp b/src/game/worldgen.cpp
new file mode 100644
index 0000000..573d03b
--- /dev/null
+++ b/src/game/worldgen.cpp
@@ -0,0 +1,29 @@
+#include "game.hpp"
+
+namespace game {
+
+void worldgen(world::tile_t *tile, world::tile_index_t x,
+ procgen::perlin_noise_t *perlin)
+{
+ float waterlevel, height;
+
+ waterlevel = perlin->get(x, 1000.0f) * 0.3f +
+ perlin->get(x, 500.0f) * 0.1f;
+
+ height = perlin->get(x, 40.0f) * 0.6f +
+ perlin->get(x, 20.0f) * 0.25f +
+ perlin->get(x, 10.0f) * 0.2f +
+ perlin->get(x, 4.0f) * 0.1f +
+ perlin->get(x, 1.0f) * 0.05f;
+
+ if (height < waterlevel)
+ tile->type = TILE_WALL;
+ else if (height < waterlevel + 0.1)
+ tile->type = TILE_DIRT;
+ else if (perlin->get(x, 3.0f) > 0.0f)
+ tile->type = TILE_WALL;
+ else
+ tile->type = TILE_DIRT;
+}
+
+}