Path find

From Bennu Wiki
Jump to navigation Jump to search


INT path_find ( <INT fileID> , <INT graphID> , <INT start_x> , <INT start_y> , <INT dest_x> , <INT dest_y> , <INT options>)


The pathfinding function is based on the A* algorithm with a heuristic value. It uses a logic map with a maze, a start position and an end position. The logic map is an 8 bit image (with palette), preferably with only 2 colors, black and white, wich indicates the walls and the paths.

Here's the bennu source code: mod_path.c, wikipedia page about pathfinding.


INT fileID - The fpg archive wich contains the map, may be 0 when the systemfile is used.
INT graphID - The bitmap (either mapcode from fpg or loaded with Map_load() into the systemfile) with the maze, see notes*.
INT start_x - The x coordniate of the start position.
INT start_y - The y coordniate of the start position.
INT dest_x - The x coordinate of the destination position.
INT dest_y - The y coordinate of the destination position.
INT options - The kind of pathfinding, PF_NODIAG , PF_REVERSE


INT : Status.

0 - The path has not been found yet.
1 - The path has been found.


Look at this tutorial: Tutorial:Pathfind_demo.


  • This function requires the use of 8 bit indexed (256 color) bitmaps for the path map, because of the logic behind it's design. The philosophy behind this is similair to a hardness (logic) map. It is perfectly possible to combine 8 bit images in 16 or 32 bit colormodes, provided that all 8 bit maps share the same colorpalette.

Functions Pathfind()Pathgetxy()Pathwall()