diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-10-21 14:46:35 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-10-21 14:46:35 +0200 |
commit | ee017fb5def1c4d372a664e5e64210ed0cd52174 (patch) | |
tree | e3c39a8a049b2a1c254ec13d6996c1bdb8bceaff /src/world.cpp | |
parent | f08fb7293382dbaf240860119d128486ada62221 (diff) |
Slightly more interesting world generation.
Diffstat (limited to 'src/world.cpp')
-rw-r--r-- | src/world.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/world.cpp b/src/world.cpp index 895eb0f..ad055c0 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -26,9 +26,11 @@ void world_t::generate_tile(tile_t *tile, tile_index_t x) waterlevel = perlin.get(x, 1000.0f) * 0.3f + perlin.get(x, 500.0f) * 0.1f; - height = perlin.get(x, 10.0f) * 0.6f + - perlin.get(x, 5.0f) * 0.25f + - perlin.get(x, 3.0f) * 0.2f; + 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 - 0.2f) tile->type = -1; @@ -41,6 +43,10 @@ void world_t::generate_tile(tile_t *tile, tile_index_t x) tile->type = 3; else tile->type = 2; + + if (height > waterlevel + 0.1f && + perlin.get(x, 2.0f) > 0.3f) + tile->type = 4; } } @@ -75,7 +81,8 @@ bool world_t::find_path(v2f_t src, v2f_t dst, rectf_t size, tile_index_t index; index = finder.base + tile_index_t(x, y); - node->accessible = (get_tile(index)->type >= 1); + node->accessible = (get_tile(index)->type >= 1 && + get_tile(index)->type <= 3); } if (!finder.find()) |