From 9591646aa002321e11b0b891d1c6e5eccd8afec8 Mon Sep 17 00:00:00 2001 From: Andrew Kesterson Date: Sun, 22 Jun 2014 13:41:58 -0700 Subject: [PATCH] Pathfind AROUND AISprites instead of through them --- moonlight/src/Util.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/moonlight/src/Util.js b/moonlight/src/Util.js index d4b2923..8c81a16 100644 --- a/moonlight/src/Util.js +++ b/moonlight/src/Util.js @@ -70,6 +70,8 @@ function nearestInGroup(sprite, group, sprite_group) { function nearestWalkableTile(spr) { + var grid = gridWithAISprites(); + function _walkable_inner(multiplier) { var startx = parseInt(Math.max((spr.x / 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) || (y == starty) || (y == endy) ) { - console.log(pathfinder_grid); - if ( pathfinder_grid.nodes[y][x].walkable == true ) { + if ( grid.nodes[y][x].walkable == true ) { console.log([x, y]); return [x, y]; }