|
SDLGameEngine
|
A* path finding. More...
Data Structures | |
| struct | SGEPATHFINDERINFO |
| holds information about a possible path More... | |
| struct | SGEPATHFINDER |
| a pathfinder struct More... | |
Defines | |
| #define | DISABLE_DIAGONAL 0 |
| #define | ENABLE_DIAGONAL 1 |
Functions | |
| SGEPATHFINDER * | sgePathFinderNew (int width, int height) |
| create a new path finder with a grid of width x height, diagonal movement enabled | |
| SGEPATHFINDER * | sgePathFinderNewDiagonal (int width, int height, int diagonal) |
| create a new path finder with a grid of width x height | |
| void | sgePathFinderDestroy (SGEPATHFINDER *p) |
| destroy a SGEPATHFINDER | |
| SGEPATHFINDERINFO * | sgePathFinderInfoNew (int x, int y, int startWeight, int targetWeight, void *parent) |
| create a new SGEPATHFINDERINFO | |
| void | sgePathFinderInfoDestroy (SGEPATHFINDERINFO *pi) |
| destroy a SGEPATHFINDERINFO | |
| void | sgePathFinderDiagonal (SGEPATHFINDER *p, int diagonal) |
| enable or disable diagonal movement | |
| void | sgePathFinderSet (SGEPATHFINDER *p, int x, int y, int value) |
| set a position in the data grid | |
| int | sgePathFinderGet (SGEPATHFINDER *p, int x, int y) |
| get the value of a position in the data grid | |
| int | sgePathFinderFind (SGEPATHFINDER *p, int startx, int starty, int destx, int desty) |
| find a path between two points on the datagrid | |
Variables | |
| int | SGEPATHFINDERINFO::y |
| the y position in the data grid | |
| int | SGEPATHFINDER::height |
| The height of the grid. | |
A* path finding.
Finds the shortest route between two points in a n by n grid.
| #define DISABLE_DIAGONAL 0 |
disable diagonal movement
Definition at line 33 of file sgepathfinder.h.
| #define ENABLE_DIAGONAL 1 |
enable diagonal movement
Definition at line 38 of file sgepathfinder.h.
| void sgePathFinderDestroy | ( | SGEPATHFINDER * | p | ) |
destroy a SGEPATHFINDER
| p | a pointer to SGEPATHFINDER |
Definition at line 32 of file sgepathfinder.c.
| void sgePathFinderDiagonal | ( | SGEPATHFINDER * | p, |
| int | diagonal | ||
| ) | [inline] |
enable or disable diagonal movement
| p | a pointer to SGEPATHFINDER |
| diagonal | YES/NO to enable of disable diagonal movement |
Definition at line 40 of file sgepathfinder.c.
| int sgePathFinderFind | ( | SGEPATHFINDER * | p, |
| int | startx, | ||
| int | starty, | ||
| int | destx, | ||
| int | desty | ||
| ) |
find a path between two points on the datagrid
| p | a pointer to SGEPATHFINDER |
| startx | the x position of the starting point |
| starty | the y position of the starting point |
| destx | the x position of the destination point |
| desty | the y position of the destination point |
The resulting path, if there was one, is saved as a SGEARRAY of SGEPATHFINDERINFO structures.
Definition at line 75 of file sgepathfinder.c.
| int sgePathFinderGet | ( | SGEPATHFINDER * | p, |
| int | x, | ||
| int | y | ||
| ) |
get the value of a position in the data grid
| p | a pointer to SGEPATHFINDER |
| x | the x position to get |
| y | the y position to get |
Definition at line 63 of file sgepathfinder.c.
| void sgePathFinderInfoDestroy | ( | SGEPATHFINDERINFO * | pi | ) |
destroy a SGEPATHFINDERINFO
| pi | a pointer to SGEPATHFINDERINFO |
Definition at line 55 of file sgepathfinder.c.
| SGEPATHFINDERINFO* sgePathFinderInfoNew | ( | int | x, |
| int | y, | ||
| int | startWeight, | ||
| int | targetWeight, | ||
| void * | parent | ||
| ) |
create a new SGEPATHFINDERINFO
| x | the x position in the grid |
| y | the y position in the grid |
| startWeight | the weight to the start |
| targetWeight | the weight to the target |
| parent | the parent SGEPATHFINDERINFO |
Definition at line 44 of file sgepathfinder.c.
| SGEPATHFINDER* sgePathFinderNew | ( | int | width, |
| int | height | ||
| ) |
create a new path finder with a grid of width x height, diagonal movement enabled
| width | the width of the data grid |
| height | the height of the data grid |
Definition at line 15 of file sgepathfinder.c.
| SGEPATHFINDER* sgePathFinderNewDiagonal | ( | int | width, |
| int | height, | ||
| int | diagonal | ||
| ) |
create a new path finder with a grid of width x height
| width | the width of the data grid |
| height | the height of the data grid |
| diagonal | YES/NO if there should be diagonal movement between the grid fields |
Definition at line 26 of file sgepathfinder.c.
| void sgePathFinderSet | ( | SGEPATHFINDER * | p, |
| int | x, | ||
| int | y, | ||
| int | value | ||
| ) |
set a position in the data grid
| p | a pointer to SGEPATHFINDER |
| x | the x position to set |
| y | the y position to set |
| value | 0 or 1 depending on if it is walkable or a obstacle |
Definition at line 59 of file sgepathfinder.c.