Pathfind AROUND AISprites instead of through them
This commit is contained in:
@@ -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");
|
||||||
|
|||||||
@@ -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;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user