Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function neighborInSequence(reference, lastNeighbor)
- local newNeighbor, costToNeighbor
- local dX, dY
- if not lastNeighbor then
- dX, dY = -1, 0
- else
- dX, dY = lastNeighbor.xTile - reference.xTile, lastNeighbor.yTile - reference.yTile
- end
- dX, dY = -dY, dX
- if dY = -1 and lastNeighbor then
- return
- end
- newNeighbor = reference.parent[reference.yTile + dY][reference.xTile + dX]
- if newNeighbor.isTraversable then
- costToNeighbor = 1
- else
- costToNeighbor = math.huge
- end
- return newNeighbor, costToNeighbor
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement