From 1c637e1ca5c0b1cf8a91f37c999aa7379fa08a8f Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Sat, 21 Oct 2017 13:17:45 +0200 Subject: Move path finding code to another file. --- src/common.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/common.hpp') diff --git a/src/common.hpp b/src/common.hpp index ced0b25..bbf83cf 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "math.hpp" @@ -112,6 +113,25 @@ namespace world { virtual void render_to(render::state_t *render) = 0; }; + + typedef struct { + bool accessible; + float dist; + } path_node_t; + + class path_finder_t { + public: + v2f_t src, dst; + path_node_t *nodes; + size_t width, height; + tile_index_t base; + std::stack current_path, shortest_path; + + ~path_finder_t(); + void setup_nodes(v2f_t src_, v2f_t dst_); + void find_r(tile_index_t index, float dist); + void find(void); + }; } namespace game { -- cgit