mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-07 03:13:15 -06:00
Removed tabs and training white space.
This commit is contained in:
@@ -2,6 +2,7 @@ from pathfinding.core.diagonal_movement import DiagonalMovement
|
||||
from pathfinding.core.grid import Grid
|
||||
from pathfinding.finder.a_star import AStarFinder
|
||||
|
||||
|
||||
def route(start, end, matrix) -> path:
|
||||
"""
|
||||
Take a matrix of the level in the form wighted numbers, a start and stop point, and return a path between them.
|
||||
@@ -10,12 +11,14 @@ def route(start, end, matrix) -> path:
|
||||
param: end: (x, y) location of the player
|
||||
param: matrix: a 2d list of the level. 0s are walls, numbers greater than 0 are weighted
|
||||
"""
|
||||
grid = Grid(matrix=matrix)
|
||||
start = grid.node(start[0],start[1])
|
||||
end = grid.node(end[0], end[1])
|
||||
|
||||
grid = Grid(matrix=matrix)
|
||||
start = grid.node(start[0], start[1])
|
||||
end = grid.node(end[0], end[1])
|
||||
finder = AStarFinder(diagonal_movement=DiagonalMovement.always)
|
||||
path, runs = finder.find_path(start, end, grid)
|
||||
|
||||
#grid.grid_str(path=path, start=start, end=end)
|
||||
return path
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user