astar bugg fix

This commit is contained in:
Ziver Koc 2007-05-07 09:48:08 +00:00
parent 8f74ca2ee5
commit 3c1e43cf40

View file

@ -33,6 +33,25 @@ public class AStar{
public List<AStarNode> startSearch(Vector2i start, Vector2i goal){
//map[goal.getX()][goal.getY()].setBlocked(false);
if(start.getX() >= map.length)
start.setX(map.length-1);
if(start.getX() < 0)
start.setX(0);
if(start.getY() >= map[0].length)
start.setY(map[0].length-1);
if(start.getY() < 0)
start.setY(0);
if(goal.getX() >= map.length)
goal.setX(map.length-1);
if(goal.getX() < 0)
goal.setX(0);
if(goal.getY() >= map[0].length)
goal.setY(map[0].length-1);
if(goal.getY() < 0)
goal.setY(0);
return pathfinder.findPath(map[start.getX()][start.getY()], map[goal.getX()][goal.getY()]);
}