diff options
Diffstat (limited to 'Pathfinder.cpp')
-rw-r--r-- | Pathfinder.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Pathfinder.cpp b/Pathfinder.cpp new file mode 100644 index 0000000..deb6040 --- /dev/null +++ b/Pathfinder.cpp @@ -0,0 +1,26 @@ +#include <algorithm> + +#include "Pathfinder.h" +#include "Museum.h" + +using namespace std; + +Pathfinder::Pathfinder(Museum & m) : museum(m) { +} + +void Pathfinder::set_visited(const XY & point) { + this->visisted[point.y * this->museum.canvas.data.columns + point.x] = true; +} + +bool Pathfinder::is_visited(const XY & point) { + size_t idx = point.y * this->museum.canvas.data.columns + point.x; + if (idx >= this->visisted.size()) return false; + return this->visisted[idx]; +} + +void Pathfinder::clear() { + CanvasData & canvas = this->museum.canvas.data; + this->visisted.resize(canvas.columns * canvas.rows); + fill(this->visisted.begin(), this->visisted.end(), false); +} + |