Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arcade/examples/platform_tutorial/17_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,4 @@ def main():
if __name__ == "__main__":
main()
main()
main()
1 change: 1 addition & 0 deletions arcade/geometry/geometry_python.py → arcade/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,4 @@ def is_point_in_polygon(x: float, y: float, polygon: PointList) -> bool:

# Return true if count is odd, false otherwise
return count % 2 == 1

39 changes: 0 additions & 39 deletions arcade/geometry/__init__.py

This file was deleted.

52 changes: 0 additions & 52 deletions arcade/geometry/geometry_shapely.py

This file was deleted.

52 changes: 40 additions & 12 deletions arcade/paths.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
"""
Classic A-star algorithm for path finding.
"""
from typing import List, Optional, Set, Tuple, Union

from arcade import (Sprite, SpriteList, check_for_collision_with_list,
get_sprites_at_point)
from arcade.math import get_distance, lerp_vec
from arcade.types import Point
from arcade import check_for_collision_with_list, SpriteList, Sprite
from typing import Union, List, Tuple, Set, Optional

try:
import shapely # noqa: F401
use_shapely = True
except ImportError:
use_shapely = False
if use_shapely:
from .paths_shapely import has_line_of_sight # noqa: F401
else:
from .paths_python import has_line_of_sight # noqa: F401


def _spot_is_blocked(position: Point,
moving_sprite: Sprite,
Expand Down Expand Up @@ -262,6 +256,39 @@ def astar_calculate_path(start_point: Point,
return revised_result


def has_line_of_sight(point_1: Point,
point_2: Point,
walls: SpriteList,
max_distance: int = -1,
check_resolution: int = 2) -> bool:
"""
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.

:param Point point_1: Start position
:param Point point_2: End position position
:param SpriteList walls: List of all blocking sprites
:param int max_distance: Max distance point 1 can see
:param int check_resolution: Check every x pixels for a sprite. Trade-off
between accuracy and speed.
"""
distance = get_distance(point_1[0], point_1[1],
point_2[0], point_2[1])
steps = int(distance // check_resolution)
for step in range(steps + 1):
step_distance = step * check_resolution
u = step_distance / distance
midpoint = lerp_vec(point_1, point_2, u)
if max_distance != -1 and step_distance > max_distance:
return False
# print(point_1, point_2, step, u, step_distance, midpoint)
sprite_list = get_sprites_at_point(midpoint, walls)
if len(sprite_list) > 0:
return False
return True


# NOTE: Rewrite this
# def dda_step(start: Point, end: Point):
# """
Expand Down Expand Up @@ -292,3 +319,4 @@ def astar_calculate_path(start_point: Point,
# y += y_inc

# return points
# return points
40 changes: 0 additions & 40 deletions arcade/paths_python.py

This file was deleted.

31 changes: 0 additions & 31 deletions arcade/paths_shapely.py

This file was deleted.

9 changes: 0 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,6 @@ ignore_missing_imports = true
module = "pytiled_parser.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "shapely.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "PyInstaller.*"
ignore_missing_imports = true





20 changes: 3 additions & 17 deletions util/update_quick_index.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Script used to create the quick index
"""
import re
import os
import re
from pathlib import Path

# The project root
Expand All @@ -15,16 +15,11 @@
'context.py': ['OpenGL Context', 'open_gl.rst'],
'drawing_support.py': ['Drawing - Utility', 'drawing_utilities.rst'],
'draw_commands.py': ['Drawing - Primitives', 'drawing_primitives.rst'],
'geometry/__init__.py': ['Geometry Support', 'geometry.rst'],
'geometry/geometry_generic.py': ['Geometry Support', 'geometry.rst'],
'geometry/geometry_shapely.py': ['Geometry Support', 'geometry.rst'],
'hitbox.py': ['Geometry Support', 'geometry.rst'],
'geometry.py': ['Geometry Support', 'geometry.rst'],
'isometric.py': ['Isometric Map Support (incomplete)', 'isometric.rst'],
'controller.py': ['Game Controller Support', 'game_controller.rst'],
'joysticks.py': ['Joystick Support', 'joysticks.rst'],
'paths.py': ['Pathfinding', 'path_finding.rst'],
'paths_python.py': ['Pathfinding', 'path_finding.rst'],
'paths_shapely.py': ['Pathfinding', 'path_finding.rst'],
'perf_info.py': ['Performance Information', 'perf_info.rst'],
'perf_graph.py': ['Performance Information', 'perf_info.rst'],
'physics_engines.py': ['Physics Engines', 'physics_engines.rst'],
Expand Down Expand Up @@ -175,15 +170,6 @@ def process_directory(directory: Path, quick_index_file):
if "test" in path.name:
continue

if "geometry_python.py" in path.name:
continue

if "geometry.py" in path.name:
continue

if "paths_python.py" in path.name:
continue

if not path.exists():
print(f"Error, can't find file: '{path.name}'")
continue
Expand All @@ -198,12 +184,12 @@ def process_directory(directory: Path, quick_index_file):
"texture": "arcade",
"texture_atlas": "arcade",
"sprite_list": "arcade",
"geometry": "geometry",
"text": "arcade",
"gui": "arcade.gui",
"property": "arcade.gui.property",
"widgets": "arcade.gui",
"tilemap": "arcade.tilemap",
"geometry.py": "arcade.geometry",
"transforms.py": "arcade.texture.transforms",
"isometric.py": "arcade.isometric",
"particles": "arcade.particles",
Expand Down