Created
May 26, 2014 19:15
-
-
Save codepaladin/d85a5d7f9f0244b774fd to your computer and use it in GitHub Desktop.
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