Pathfind AROUND AISprites instead of through them

This commit is contained in:
2014-06-22 13:41:58 -07:00
parent b75ec6d5a5
commit 9591646aa0

View File

@@ -70,6 +70,8 @@ function nearestInGroup(sprite, group, sprite_group) {
function nearestWalkableTile(spr) function nearestWalkableTile(spr)
{ {
var grid = gridWithAISprites();
function _walkable_inner(multiplier) { function _walkable_inner(multiplier) {
var startx = parseInt(Math.max((spr.x / 32) - (1 * multiplier), 0)); var startx = parseInt(Math.max((spr.x / 32) - (1 * multiplier), 0));
var starty = parseInt(Math.max((spr.y / 32) - (1 * multiplier), 0)); var starty = parseInt(Math.max((spr.y / 32) - (1 * multiplier), 0));
@@ -82,8 +84,7 @@ function nearestWalkableTile(spr)
(x == startx && y == endy) || (x == startx && y == endy) ||
(y == starty) || (y == starty) ||
(y == endy) ) { (y == endy) ) {
console.log(pathfinder_grid); if ( grid.nodes[y][x].walkable == true ) {
if ( pathfinder_grid.nodes[y][x].walkable == true ) {
console.log([x, y]); console.log([x, y]);
return [x, y]; return [x, y];
} }