Javascript A* path finding

Posted by Veyha on Game Development See other posts from Game Development or by Veyha
Published on 2012-06-16T08:42:52Z Indexed on 2012/06/16 21:23 UTC
Read the original article Hit count: 270

Filed under:
|

I am trying to learn A* path finding. I am using this library - https://github.com/qiao/PathFinding.js

But there is one thing I don't understand how to do.

To find a path from player.x/player.y (player.x and player.y are both 0) to 10/10 I use this code

var path = finder.findPath(player.x, player.y, 10, 10, grid);

This gives an array of where I need to move, but how do I apply this array to my player.x and player.y?

The path structure looks like this

path = [[0, 0], [1, 0], [1, 1], ..., [10, 10]]

© Game Development or respective owner

Related posts about JavaScript

Related posts about path-finding