class arcade.AStarBarrierList(moving_sprite: Sprite, blocking_sprites: SpriteList, grid_size: int, left: int, right: int, bottom: int, top: int)[source]#


Class that manages a list of barriers that can be encountered during A* path finding.

  • moving_sprite – Sprite that will be moving

  • blocking_sprites – Sprites that can block movement

  • grid_size – Size of the grid, in pixels

  • left – Left border of playing field

  • right – Right border of playing field

  • bottom – Bottom of playing field

  • top – Top of playing field

  • barrier_list – SpriteList of barriers to use in _AStarSearch, None if not recalculated


Recalculate blocking sprites.

arcade.astar_calculate_path(start_point: Tuple[float, float], end_point: Tuple[float, float], astar_barrier_list: AStarBarrierList, diagonal_movement: bool = True) List[Tuple[float, float]] | None[source]#

Calculates the path using AStarSearch Algorithm and returns the path

  • start_point – Where it starts

  • end_point – Where it ends

  • astar_barrier_list – AStarBarrierList with the boundries to use in the AStarSearch Algorithm

  • diagonal_movement – Whether of not to use diagonals in the AStarSearch Algorithm


List of points(the path), or None if no path is found

arcade.has_line_of_sight(observer: Tuple[float, float], target: Tuple[float, float], walls: SpriteList, max_distance: float = inf, check_resolution: int = 2) bool[source]#

Determine if we have line of sight between two points.

  • observer – Start position

  • target – End position position

  • walls – List of all blocking sprites

  • max_distance – Max distance point 1 can see

  • check_resolution – Check every x pixels for a sprite. Trade-off between accuracy and speed.


Try to make sure spatial hashing is enabled on walls!

If spatial hashing is not enabled, this function may run very slowly!


Whether or not oberver to target is blocked by any wall in walls