- pathfun: git repository, download
- pathfun-editor: git repository, download
Hi everyone,
I wanted to share pathfun, a 2d pathfinding library I've been working on. I made it as part of a LÖVE point & click adventure game engine I've been working on, and since it's self-contained I decided to release it on its own.
The pathfinding algorithm is a Lua translation of the one from the Godot Engine, which uses the funnel algorithm. The rest is my own work.
Features
- Pure Lua library
- Navigation area described by one or more polygonal maps
- Supports navigation areas made up of disjoint pieces and/or with holes
- Supports dynamically hiding/unhiding parts of the navigation area to add/ remove obstacles or disconnect/connect regions
- Uses integer coordinates to make calculations exact and avoid problems with floating point precision
- Comes with html documentation
Editor
The navigation area data read by the library is a list of polygon maps consisting of convex polygons decompositions (see the documentation for more information), looking like this:
Code: Select all
polygon_maps = {
{
{{520,441},{456,429},{454,342},{658,370},{666,436}},
{{520,441},{666,436},{549,498}},
{{822,391},{880,372},{868,446},{747,431}},
{{822,391},{747,431},{754,360},{796,346}}
},
{
{{747,431},{666,436},{658,370},{754,360}},
hidden = true,
name = "bridge"
}
}
Features:
- Pre-built binaries available for Linux, Windows, and macos (cimgui and clipper need to be compiled otherwise)
- Visual editing the navigation area by adding or subtracting polygons in an intuitive way
- Testing mode to test pathfinding on the navigation area using pathfun
- Help window with instructions on how to use the editor
- Exports a .lua file that returns the navigation data expected from pathfun when required from Lua
Editing the editor
You will probably need to make some changes to the source code of pathfun-editor to use it in your project, as you will want to draw the polygons on top of your background image.
In the simplest case you will need to:
- Add code to load the background image into the editor
- Draw the image at the very beginning of love.draw in the draw.lua file
- You may also want to save the location of the background image as a field in the exported Lua table and that read it when the file is loaded