Class AStarPathFinder
java.lang.Object
de.gurkenlabs.litiengine.entities.behavior.PathFinder
de.gurkenlabs.litiengine.entities.behavior.AStarPathFinder
A pathfinder implementation based on the A* algorithm. The A* algorithm is used to find the shortest path between two points on a grid, taking into
account obstacles and walkable areas.
-
Constructor Summary
ConstructorsConstructorDescriptionAStarPathFinder(AStarGrid grid) Instantiates a new A* pathfinder with a predefined grid.AStarPathFinder(IMap map) Instantiates a new A* pathfinder using the map's size and the map's tile size as the grid node size.AStarPathFinder(IMap map, int gridNodeSize) Instantiates a new A* pathfinder using the map's size and a specified grid node size.AStarPathFinder(Dimension size, int gridNodeSize) Instantiates a new A* pathfinder with a grid of the specified size and node size. -
Method Summary
Methods inherited from class de.gurkenlabs.litiengine.entities.behavior.PathFinder
applyPathMargin, findDirectPath, intersectsWithAnyCollisionBox
-
Constructor Details
-
AStarPathFinder
Instantiates a new A* pathfinder with a predefined grid.- Parameters:
grid- the grid used for pathfinding
-
AStarPathFinder
Instantiates a new A* pathfinder with a grid of the specified size and node size.- Parameters:
size- the dimensions of the gridgridNodeSize- the size of each grid node
-
AStarPathFinder
Instantiates a new A* pathfinder using the map's size and a specified grid node size.- Parameters:
map- the map used for pathfindinggridNodeSize- the size of each grid node
-
AStarPathFinder
Instantiates a new A* pathfinder using the map's size and the map's tile size as the grid node size.- Parameters:
map- the map used for pathfinding
-
-
Method Details
-
findPath
Finds a path from the entity's current position to the target using the A* algorithm. If no obstacles are present between the start and the target, a direct path is used.- Specified by:
findPathin classPathFinder- Parameters:
entity- the mobile entity for which the path is calculatedtarget- the target point of the path- Returns:
- the calculated path, or null if no path can be found
-
getGrid
Gets the grid used by this A* pathfinder.- Returns:
- the grid used for pathfinding
-