Quote:
Originally Posted by Robin
Couldn't find any decent docs for this, anyone want to point me in the right direction? 
|
I experimented with this a few days ago actually, this was a small sample I came up with:
PHP Code:
function onCreated() {
temp.walkable = {0, 2};
temp.blocking = {1};
temp.stopping = {2};
temp.map = {
{0, 1, 1, 0, 1, 1, 1, 1, 1, 1},
{0, 0, 0, 0, 0, 0, 0, 1, 1, 1},
{0, 0, 1, 1, 1, 1, 0, 1, 1, 1},
{1, 0, 0, 0, 1, 1, 0, 0, 1, 1},
{1, 1, 0, 1, 1, 1, 1, 0, 2, 1},
};
// tiles, walkable, blocking, stopping, non-stopping, startx, starty, length
temp.path = findpathinarray(map, walkable, blocking, stopping, null, 0, 0, 20);
echo(path);
}
In this case, it returns:
"0,0","1,0","1,1","1,2","1,3","1,4","1,5","1,6","2 ,6","3,6","3,7","4,7","4,8"
You basically make a multidimensional array containing "tiletypes" and pass in the types it can and cannot walk on, as well as where it can stop.
You can also ignore the "walkable" types if everything not in blocking are walkable:
PHP Code:
temp.path = findpathinarray(map, null, blocking, stopping, null, 0, 0, 50);