Hello,
Just finish my astar pathfinding : you can check the demo here : Demo
Left click to put the starting point.
Right click to put the end point.
The source code is on the demo page.
It’s very simple to use this pathfinding. All you need to do is call the method getPath() in Pathfinding. Here is the signature of this method :
public Path getPath(Location start, Location end, Map map);
Currently only the pathfinding for an 2D grid map is implemented. The signature for this one is as follow :
public GridPath getPath(Location start, Location end, Map map);
The location and the map need be respectively GridLocation and GridMap. Here is an example of how to build an 2D grid map :
map = new GridMap(sizeX, sizeY);
for(int i=0; i<sizeX; i++){
for(int j=0; j<sizeY; j++){
int value;
if(Math.random() > 0.32){
value = 1;
}else{
value = GridMap.WALL;
}
map.set(i, j, value);
}
}