寻路#

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

基类:

管理在A*路径查找过程中可能遇到的障碍列表的类。

参数:
  • moving_sprite -- 将会移动的精灵

  • blocking_sprites -- 可以阻止移动的精灵

  • grid_size -- 网格的大小,以像素为单位

  • left -- 比赛场地的左边界

  • right -- 比赛场地的右边界

  • bottom -- 竞技场底部

  • top -- 一流的运动场

  • barrier_list -- 要在_AStarSearch中使用的障碍的SpriteList,如果未重新计算,则为None

recalculate()[源代码]#

重新计算阻挡精灵。

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[源代码]#

使用AStarSearch算法计算路径并返回路径

参数:
  • start_point -- 从哪里开始

  • end_point -- 它在哪里结束

  • astar_barrier_list -- 包含要在AStarSearch算法中使用的边界的A StarBarrierList

  • diagonal_movement -- 在AStarSearch算法中是否使用对角线

返回:

点列表(路径),如果未找到路径,则为无

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

确定我们在两点之间是否有视线。

参数:
  • observer -- 起始位置

  • target -- 结束位置位置

  • walls -- 所有阻止精灵的列表

  • max_distance -- 点1可以看到的最大距离

  • check_resolution -- 检查每个x像素中是否有精灵。在准确性和速度之间进行权衡。

警告

尝试确保在上启用了空间哈希 walls 好了!

如果没有启用空间散列,此函数的运行速度可能会非常慢!

返回:

越过目标是否被墙中的任何一堵墙挡住