Jamie Slowgrove - MGP Assignment 2 - JAM
 All Classes Namespaces Files Functions Variables Macros
Public Member Functions | Private Member Functions | Private Attributes | List of all members
JAM_AStar Class Reference

Creates an object for A* path finding. More...

#include <AStar.h>

Collaboration diagram for JAM_AStar:
Collaboration graph

Public Member Functions

 JAM_AStar (int xNodes, int yNodes, float nodeWidth, float nodeHeight)
 
 ~JAM_AStar ()
 
void setDangerNode (int nodeXIndex, int nodeYIndex)
 
void setSafeNode (int nodeXIndex, int nodeYIndex)
 
void findNewPath (int startX, int startY, int endX, int endY)
 
JAM_Vec2 getNextPathNode ()
 
void drawLists (SDL_Renderer *renderer)
 

Private Member Functions

void checkNodes (int parentX, int parentY)
 
void nodeTest (int parentX, int parentY, int testX, int testY, int cost)
 
void findNextNode ()
 
void findBestPath ()
 

Private Attributes

std::vector< std::vector
< JAM_Node * > > 
nodes
 
std::vector< JAM_NodeopenList
 
std::vector< JAM_NodeclosedList
 
std::vector< JAM_NodebestPath
 
int xNodes
 
int yNodes
 
int currentX
 
int currentY
 
int endX
 
int endY
 
int startX
 
int startY
 
JAM_Vec2 nodeDimensions
 

Detailed Description

Creates an object for A* path finding.

Author
Jamie Slowgrove Reference ~ This is a modified version of my A* path-finding from my AI assignment.

Constructor & Destructor Documentation

JAM_AStar::JAM_AStar ( int  xNodes,
int  yNodes,
float  nodeWidth,
float  nodeHeight 
)

Constructs the AStar object.

Parameters
xNodesThe number of nodes in a row.
yNodesThe number of rows in the map.
nodeWidthThe width of a node.
nodeHeightThe height of a node.
JAM_AStar::~JAM_AStar ( )

Destructs the AStar object.

Member Function Documentation

void JAM_AStar::checkNodes ( int  parentX,
int  parentY 
)
private

Check the surrounding nodes.

Parameters
parentXThe parent node x index value.
parentYThe parent node y index value.

Here is the call graph for this function:

Here is the caller graph for this function:

void JAM_AStar::drawLists ( SDL_Renderer *  renderer)

Displays the open and closed lists.

Parameters
rendererA pointer to the renderer.

Here is the caller graph for this function:

void JAM_AStar::findBestPath ( )
private

Find the best path.

Here is the call graph for this function:

Here is the caller graph for this function:

void JAM_AStar::findNewPath ( int  startX,
int  startY,
int  endX,
int  endY 
)

Finds a new path to follow.

Parameters
startXThe start x index value.
startYThe start y index value.
endXThe end x index value.
endYThe end y index value.

Here is the call graph for this function:

Here is the caller graph for this function:

void JAM_AStar::findNextNode ( )
private

Find the next node.

Here is the caller graph for this function:

JAM_Vec2 JAM_AStar::getNextPathNode ( )

Getter # Gets the position of the next node in the path.

Returns
The Node position.
void JAM_AStar::nodeTest ( int  parentX,
int  parentY,
int  testX,
int  testY,
int  cost 
)
private

Test the node for the open list setup.

Parameters
parentXThe parent x index value.
parentYThe parent y index value.
testXThe test x index value.
testYThe test y index value.
costThe cost to add to the node.

Here is the call graph for this function:

Here is the caller graph for this function:

void JAM_AStar::setDangerNode ( int  nodeXIndex,
int  nodeYIndex 
)

Setter # Sets the Node at the inputed index to a danger Node.

Parameters
nodeXIndexThe x index of the Node.
nodeYIndexThe y index of the Node.

Here is the caller graph for this function:

void JAM_AStar::setSafeNode ( int  nodeXIndex,
int  nodeYIndex 
)

Setter # Sets the Node at the inputed index to a safe Node.

Parameters
nodeXIndexThe x index of the Node.
nodeYIndexThe y index of the Node.

Here is the caller graph for this function:

Member Data Documentation

std::vector<JAM_Node> JAM_AStar::bestPath
private

The array of Nodes for the best path.

std::vector<JAM_Node> JAM_AStar::closedList
private

The closed list of Nodes.

int JAM_AStar::currentX
private

The current node index.

int JAM_AStar::currentY
private
int JAM_AStar::endX
private

The end node index.

int JAM_AStar::endY
private
JAM_Vec2 JAM_AStar::nodeDimensions
private

The Dimensions of a node.

std::vector<std::vector<JAM_Node*> > JAM_AStar::nodes
private

The arrays of Nodes.

std::vector<JAM_Node> JAM_AStar::openList
private

The open list of Nodes.

int JAM_AStar::startX
private

The start node index.

int JAM_AStar::startY
private
int JAM_AStar::xNodes
private

The number of nodes.

int JAM_AStar::yNodes
private

The documentation for this class was generated from the following files: