astar bugg fix
This commit is contained in:
parent
8f74ca2ee5
commit
3c1e43cf40
1 changed files with 19 additions and 0 deletions
|
|
@ -33,6 +33,25 @@ public class AStar{
|
||||||
|
|
||||||
public List<AStarNode> startSearch(Vector2i start, Vector2i goal){
|
public List<AStarNode> startSearch(Vector2i start, Vector2i goal){
|
||||||
//map[goal.getX()][goal.getY()].setBlocked(false);
|
//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()]);
|
return pathfinder.findPath(map[start.getX()][start.getY()], map[goal.getX()][goal.getY()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue