Pathfind AROUND AISprites instead of through them

This commit is contained in:
2014-06-22 13:26:29 -07:00
parent cc03e96970
commit 801b50bf16
2 changed files with 16 additions and 1 deletions

View File

@@ -244,7 +244,7 @@ var AISprite = function(game, x, y, key, frame) {
parseInt(this.y/32), parseInt(this.y/32),
pos[0], pos[0],
pos[1], pos[1],
pathfinder_grid.clone() gridWithAISprites()
); );
prevpoint = [this.x, this.y]; prevpoint = [this.x, this.y];
console.log("New path has at most " + maxsteps + " steps in it"); console.log("New path has at most " + maxsteps + " steps in it");

View File

@@ -247,3 +247,18 @@ function setSpriteMovement(spr, velocity)
} }
} }
function genericGridClone()
{
return pathfinder_grid.clone();
}
function gridWithAISprites()
{
var grid = pathfinder_grid.clone();
var aiSprites = game.state.states.game.aiSprites;
for ( var i = 0 ; i < aiSprites.length ; i++ ) {
var spr = aiSprites.getChildAt(i);
grid.nodes[parseInt(spr.y/32)][parseInt(spr.x/32)].walkable = false;
}
return grid;
}