diff options
author | Paweł Redman <pawel.redman@gmail.com> | 2017-10-21 13:17:45 +0200 |
---|---|---|
committer | Paweł Redman <pawel.redman@gmail.com> | 2017-10-21 14:26:17 +0200 |
commit | 1c637e1ca5c0b1cf8a91f37c999aa7379fa08a8f (patch) | |
tree | 08c9782329b49d98b877833fe74722088985c2be /src/common.hpp | |
parent | 20b189455545db5688ed4f14d2966380137ee2db (diff) |
Move path finding code to another file.
Diffstat (limited to 'src/common.hpp')
-rw-r--r-- | src/common.hpp | 20 |
1 files changed, 20 insertions, 0 deletions
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 <map> #include <list> #include <unordered_set> +#include <stack> #include <SFML/Graphics.hpp> #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<v2f_t> 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 { |