Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
-- find the path from point A to point B
function getPath()
-- create a Jumper Grid object by passing in our map table
local grid = Grid(map)
-- Creates a pathfinder object using Jump Point Search
local pather = Pathfinder(grid, 'JPS', walkable)
pather:setMode("ORTHOGONAL")
-- Calculates the path, and its length
local path = pather:getPath(startX,startY, endX,endY)
if path then
for node, count in path:nodes() do
print(('Step: %d - x: %d - y: %d'):format(count, node:getX(), node:getY()))
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment