Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef GAME_AST_H
- #define GAME_AST_H
- #include <iostream>
- #include <vector>
- #include <math.h>
- struct AST_Tile
- {
- float m_x, m_y;
- };
- struct AST_Node
- {
- float m_x, m_y, m_f, m_g, m_h;
- AST_Node* m_parent;
- };
- class Game_Graph
- {
- std::vector<AST_Tile>m_tiles;
- unsigned int m_w, m_h;
- public:
- Game_Graph(){};
- Game_Graph(int w, int h, std::vector<AST_Tile>tiles) :m_w(w), m_h(h), m_tiles(tiles){};
- void Set(int w, int h, std::vector<AST_Tile>tiles);
- inline unsigned int Get_W(){return m_w;}
- inline unsigned int Get_H(){return m_h;}
- AST_Tile Get_XY_Tile(unsigned int x, unsigned int y);
- };
- class Game_AST
- {
- std::vector<AST_Node>m_open_list, m_closed_list;
- Game_Graph m_graph;
- float (*m_Heuritstic)(AST_Tile t1, AST_Tile t2);
- public:
- Game_AST();
- Game_AST(Game_Graph graph, float (*heuritstic)(AST_Tile t1, AST_Tile t2));
- ~Game_AST(){};
- void Set_Graph(Game_Graph graph);
- void Set_Heurisitc(float (*heuritstic)(AST_Tile t1, AST_Tile t2));
- std::vector<AST_Tile> Get_Path(float sx, float sy, float dx, float dy);
- };
- /*
- Heuristics
- */
- float Manhattan_Distance(AST_Tile t1, AST_Tile t2);
- float Euclidean_Distance(AST_Tile t1, AST_Tile t2);
- #endif // GAME_AST_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement