Pathfinding#

arcade.AStarBarrierList#

class arcade.AStarBarrierList(moving_sprite: arcade.sprite.Sprite, blocking_sprites: arcade.sprite_list.sprite_list.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.

Parameters
  • moving_sprite (Sprite) – Sprite that will be moving

  • blocking_sprites (SpriteList) – Sprites that can block movement

  • grid_size (int) – Size of the grid, in pixels

  • left (int) – Left border of playing field

  • right (int) – Right border of playing field

  • bottom (int) – Bottom of playing field

  • top (int) – Top of playing field

recalculate()[source]#

Recalculate blocking sprites.

arcade.astar_calculate_path#

arcade.astar_calculate_path(start_point: Union[Tuple[float, float], List[float]], end_point: Union[Tuple[float, float], List[float]], astar_barrier_list: arcade.paths.AStarBarrierList, diagonal_movement=True)[source]#
Parameters
  • start_point (Point) –

  • end_point (Point) –

  • astar_barrier_list (AStarBarrierList) –

  • diagonal_movement (bool) –

Returns: List

arcade.has_line_of_sight#

arcade.has_line_of_sight(point_1: Union[Tuple[float, float], List[float]], point_2: Union[Tuple[float, float], List[float]], walls: arcade.sprite_list.sprite_list.SpriteList, max_distance: int = - 1, check_resolution: int = 2)[source]#

Determine if we have line of sight between two points. Try to make sure that spatial hashing is enabled on the wall SpriteList or this will be very slow.

Parameters
  • point_1 (Point) – Start position

  • point_2 (Point) – End position position

  • walls (SpriteList) – List of all blocking sprites

  • max_distance (int) – Max distance point 1 can see

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