Created
April 21, 2014 15:26
-
-
Save codepaladin/11145940 to your computer and use it in GitHub Desktop.
Find Jumper Path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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