SDLGameEngine

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Data Structures | Defines | Functions | Variables

# SgePathFinder

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.

## Detailed Description

A* path finding.

Finds the shortest route between two points in a n by n grid.

## Define Documentation

#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.

## Function Documentation

void sgePathFinderDestroy | ( | SGEPATHFINDER * | p | ) |

destroy a SGEPATHFINDER

Parameters:

  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

Parameters:

  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

Parameters:

  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

Returns:
  YES/NO depending if there was a solution possible

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

Parameters:

  p | a pointer to SGEPATHFINDER
  x | the x position to get
  y | the y position to get

Returns:
  0 if the position is walkable, 1 if there is a obstacle on it

Definition at line 63 of file sgepathfinder.c.

void sgePathFinderInfoDestroy | ( | SGEPATHFINDERINFO * | pi | ) |

destroy a SGEPATHFINDERINFO

Parameters:

  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

Parameters:

  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

Returns:
  a pointer to 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

Parameters:

  width | the width of the data grid
  height | the height of the data grid

Returns:
  a pointer to SGEPATHFINDER

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

Parameters:

  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

Returns:
  a pointer to SGEPATHFINDER

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

Parameters:

  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.

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines