Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #ifndef GAME_AST_H
  2. #define GAME_AST_H
  3.  
  4. #include <iostream>
  5. #include <vector>
  6. #include <math.h>
  7.  
  8. struct AST_Tile
  9. {
  10. float m_x, m_y;
  11. };
  12.  
  13. struct AST_Node
  14. {
  15. float m_x, m_y, m_f, m_g, m_h;
  16. AST_Node* m_parent;
  17. };
  18.  
  19. class Game_Graph
  20. {
  21. std::vector<AST_Tile>m_tiles;
  22. unsigned int m_w, m_h;
  23.  
  24. public:
  25.  
  26. Game_Graph(){};
  27. Game_Graph(int w, int h, std::vector<AST_Tile>tiles) :m_w(w), m_h(h), m_tiles(tiles){};
  28.  
  29. void Set(int w, int h, std::vector<AST_Tile>tiles);
  30.  
  31. inline unsigned int Get_W(){return m_w;}
  32. inline unsigned int Get_H(){return m_h;}
  33.  
  34. AST_Tile Get_XY_Tile(unsigned int x, unsigned int y);
  35.  
  36. };
  37.  
  38. class Game_AST
  39. {
  40. std::vector<AST_Node>m_open_list, m_closed_list;
  41. Game_Graph m_graph;
  42.  
  43.  
  44. float (*m_Heuritstic)(AST_Tile t1, AST_Tile t2);
  45.  
  46. public:
  47.  
  48. Game_AST();
  49. Game_AST(Game_Graph graph, float (*heuritstic)(AST_Tile t1, AST_Tile t2));
  50. ~Game_AST(){};
  51.  
  52. void Set_Graph(Game_Graph graph);
  53. void Set_Heurisitc(float (*heuritstic)(AST_Tile t1, AST_Tile t2));
  54.  
  55. std::vector<AST_Tile> Get_Path(float sx, float sy, float dx, float dy);
  56. };
  57.  
  58. /*
  59. Heuristics
  60. */
  61.  
  62. float Manhattan_Distance(AST_Tile t1, AST_Tile t2);
  63. float Euclidean_Distance(AST_Tile t1, AST_Tile t2);
  64.  
  65. #endif // GAME_AST_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement