You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
881 B
61 lines
881 B
9 years ago
|
#pragma once
|
||
|
#include <map>
|
||
|
#include "App.h"
|
||
|
#include <unordered_map>
|
||
|
|
||
|
class Pather;
|
||
|
|
||
|
class node {
|
||
|
public:
|
||
|
|
||
|
node(sf::Vector2i XY, int h, int cF, int cL, node* p, Pather* pather_);
|
||
|
node();
|
||
|
~node();
|
||
|
|
||
|
sf::Vector2i xy;
|
||
|
|
||
|
// Ugh, pointers, ugh c++
|
||
|
node* parent;
|
||
|
int hueristic;
|
||
|
int cameFrom;
|
||
|
int closedList;
|
||
|
Pather* pather;
|
||
|
|
||
|
void neighbors();
|
||
|
private:
|
||
|
|
||
|
};
|
||
|
|
||
|
class Pather {
|
||
|
public:
|
||
|
Pather(Map* map_);
|
||
|
~Pather();
|
||
|
|
||
|
Map* map;
|
||
|
|
||
|
std::unordered_map<node*, int> openList;
|
||
|
std::unordered_map<node*, int> closedList;
|
||
|
int visitedMap[App::WINDOW_HEIGHT][App::WINDOW_WIDTH];
|
||
|
|
||
|
std::vector<int> pathTo(sf::Vector2i start, sf::Vector2i end);
|
||
|
std::vector<int> loop();
|
||
|
std::vector<int> returnPath();
|
||
|
|
||
|
sf::Vector2i getEndNodePosition();
|
||
|
|
||
|
node* start_node;
|
||
|
node* active_node;
|
||
|
|
||
|
bool no_path = false;
|
||
|
bool early_exit;
|
||
|
|
||
|
private:
|
||
|
|
||
|
std::vector<int> path_list;
|
||
|
node* end_node;
|
||
|
|
||
|
};
|
||
|
|
||
|
|
||
|
|