Hi all,
I would like to share a library I am working on.
Jumper is a pathfinding library designed for 2D grid-based games. It aims to be fast and lightweight. It features a wide range of search algorithms, built within a clean interface with chaining features which makes it very friendly and easy to use.
Jumper is written in pure Lua. Thus, it is not framework-related and can be used in any project embedding Lua code.
Here is a simple usage example for Jumper:
-- Usage Example -- First, set a collision map local map = { {0,1,0,1,0}, {0,1,0,1,0}, {0,1,1,1,0}, {0,0,0,0,0}, } -- Value for walkable tiles local walkable = 0 -- Library setup local Grid = require ("jumper.grid") -- The grid class local Pathfinder = require ("jumper.pathfinder") -- The pathfinder lass -- Creates a grid object local grid = Grid(map) -- Creates a pathfinder object using Jump Point Search local myFinder = Pathfinder(grid, 'JPS', walkable) -- Define start and goal locations coordinates local startx, starty = 1,1 local endx, endy = 5,1 -- Calculates the path, and its length local path = myFinder:getPath(startx, starty, endx, endy) if path then print(('Path found! Length: %.2f'):format(path:getLength())) for node, count in path:nodes() do print(('Step: %d - x: %d - y: %d'):format(count, node.x, node.y)) end end
The output:
--> Path found! Length: 8.83 --> Step: 1 - x: 1 - y: 1 --> Step: 2 - x: 1 - y: 3 --> Step: 3 - x: 2 - y: 4 --> Step: 4 - x: 4 - y: 4 --> Step: 5 - x: 5 - y: 3 --> Step: 6 - x: 5 - y: 1
The latest stable release of Jumper (1.8.1) can be found on github. It goes along with a very comprenhensive README tutorial, to help get your hands ready with the library and a full HTML documentation.
- Project page
- Development version source code (not to be used!)
- Documentation
- Latest stable : v1.8.1 (recommended)
Important Note for Codea Users:
As-is, Jumper cannot work with Codea because of its internal modularisation (the source code is splitted in different files, for clarity and easier maintenance). However, thanks to kind contribution of Codea users, there are two alternative variations of a single-file version of the library, for your perusal, as Github Gits:
- Jumper for Codea (by @Ignatz)
- Jumper for Codea (by @brookesi)
Thanks reading!