Jamie Slowgrove - MGP Assignment 2 - JAM
 All Classes Namespaces Files Functions Variables Macros
AStar.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <SDL.h>
4 #include <vector>
5 #include "Vec2.h"
6 #include "Node.h"
7 
13 class JAM_AStar
14 {
15 private:
17  std::vector<std::vector<JAM_Node*>> nodes;
19  std::vector<JAM_Node> openList;
21  std::vector<JAM_Node> closedList;
23  std::vector<JAM_Node> bestPath;
25  int xNodes, yNodes;
29  int endX, endY;
31  int startX, startY;
34 
40  void checkNodes(int parentX, int parentY);
41 
50  void nodeTest(int parentX, int parentY, int testX, int testY, int cost);
51 
55  void findNextNode();
56 
60  void findBestPath();
61 
62 public:
70  JAM_AStar(int xNodes, int yNodes, float nodeWidth, float nodeHeight);
71 
75  ~JAM_AStar();
76 
82  void setDangerNode(int nodeXIndex, int nodeYIndex);
83 
89  void setSafeNode(int nodeXIndex, int nodeYIndex);
90 
98  void findNewPath(int startX, int startY, int endX, int endY);
99 
105 
110  void drawLists(SDL_Renderer* renderer);
111 };
void nodeTest(int parentX, int parentY, int testX, int testY, int cost)
Definition: AStar.cpp:167
~JAM_AStar()
Definition: AStar.cpp:29
int currentX
Definition: AStar.h:27
std::vector< std::vector< JAM_Node * > > nodes
Definition: AStar.h:17
void setSafeNode(int nodeXIndex, int nodeYIndex)
Definition: AStar.cpp:53
int xNodes
Definition: AStar.h:25
int startX
Definition: AStar.h:31
void findNextNode()
Definition: AStar.cpp:203
void findNewPath(int startX, int startY, int endX, int endY)
Definition: AStar.cpp:62
int yNodes
Definition: AStar.h:25
void findBestPath()
Definition: AStar.cpp:254
JAM_AStar(int xNodes, int yNodes, float nodeWidth, float nodeHeight)
Definition: AStar.cpp:6
JAM_Vec2 nodeDimensions
Definition: AStar.h:33
std::vector< JAM_Node > openList
Definition: AStar.h:19
void setDangerNode(int nodeXIndex, int nodeYIndex)
Definition: AStar.cpp:44
int endY
Definition: AStar.h:29
std::vector< JAM_Node > closedList
Definition: AStar.h:21
void checkNodes(int parentX, int parentY)
Definition: AStar.cpp:137
int endX
Definition: AStar.h:29
Creates an object for A* path finding.
Definition: AStar.h:13
void drawLists(SDL_Renderer *renderer)
Definition: AStar.cpp:297
JAM_Vec2 getNextPathNode()
Definition: AStar.cpp:239
int startY
Definition: AStar.h:31
int currentY
Definition: AStar.h:27
std::vector< JAM_Node > bestPath
Definition: AStar.h:23
Creates an Vec2 structure with functions. Creates an Vec2 structure with overloaded operators to crea...
Definition: Vec2.h:9