Skip to content

Instantly share code, notes, and snippets.

@codepaladin
Created April 21, 2014 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codepaladin/11145940 to your computer and use it in GitHub Desktop.
Save codepaladin/11145940 to your computer and use it in GitHub Desktop.
Find Jumper Path
-- 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