From 886a97593c1da1351f978c3dc39d9c1ea2ab57d9 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 21 Oct 2017 14:26:40 +0200 Subject: First working path finding. --- src/world.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/world.cpp') diff --git a/src/world.cpp b/src/world.cpp index 8d0b1fb..307374c 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -15,7 +15,7 @@ tile_index_t tile_index_at(v2f_t x) world_t::world_t(void) { - prng.seed(124); + prng.seed(125); perlin.generate(&prng, 32); } @@ -26,10 +26,9 @@ 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, 60.0f) * 0.6f + - perlin.get(x, 30.0f) * 0.25f + - perlin.get(x, 14.0f) * 0.1f + - perlin.get(x, 6.0f) * 0.05f; + height = perlin.get(x, 10.0f) * 0.6f + + perlin.get(x, 5.0f) * 0.25f + + perlin.get(x, 3.0f) * 0.2f; if (height < waterlevel - 0.2f) tile->type = -1; @@ -67,6 +66,7 @@ bool world_t::find_path(v2f_t src, v2f_t dst, rectf_t size, std::list *path) { path_finder_t finder; + bool rv; finder.setup_nodes(src, dst); @@ -80,6 +80,7 @@ bool world_t::find_path(v2f_t src, v2f_t dst, rectf_t size, } finder.find(); + rv = finder.export_path(path); debug.clear(); @@ -88,13 +89,14 @@ bool world_t::find_path(v2f_t src, v2f_t dst, rectf_t size, path_node_t *node = finder.nodes + y * finder.width + x; std::stringstream ss; - ss << finder.base + tile_index_t(x, y) << "\n"; - ss << node->dist; + ss << "LT " << tile_index_t(x, y) << "\n"; + ss << " T " << finder.base + tile_index_t(x, y) << "\n"; + ss << " d " << node->dist; debug.push_back((debug_t){finder.base + tile_index_t(x, y), ss.str()}); } - return false; + return rv; } sector_t *world_t::get_sector(sector_index_t index) -- cgit