summaryrefslogtreecommitdiff
path: root/src/world.cpp
diff options
context:
space:
mode:
authorPaweł Redman <pawel.redman@gmail.com>2017-10-21 14:26:40 +0200
committerPaweł Redman <pawel.redman@gmail.com>2017-10-21 14:26:40 +0200
commit886a97593c1da1351f978c3dc39d9c1ea2ab57d9 (patch)
tree4d8c5d456c8c78a7d7639b4cd608435a5f103f01 /src/world.cpp
parent1c637e1ca5c0b1cf8a91f37c999aa7379fa08a8f (diff)
First working path finding.
Diffstat (limited to 'src/world.cpp')
-rw-r--r--src/world.cpp18
1 files changed, 10 insertions, 8 deletions
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<v2f_t> *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)