diff --git a/arcade/__init__.py b/arcade/__init__.py index a4c812d3e..7a13f3c33 100644 --- a/arcade/__init__.py +++ b/arcade/__init__.py @@ -199,9 +199,12 @@ def configure_logging(level: int | None = None): from .tilemap import read_tmx from .tilemap import TileMap -from .pymunk_physics_engine import PymunkPhysicsEngine -from .pymunk_physics_engine import PymunkPhysicsObject -from .pymunk_physics_engine import PymunkException +try: + from .pymunk_physics_engine import PymunkPhysicsEngine + from .pymunk_physics_engine import PymunkPhysicsObject + from .pymunk_physics_engine import PymunkException +except ImportError: + print("Pymunk is not installed. Pymunk physics engine will not be available.") from .version import VERSION diff --git a/arcade/camera/camera_2d.py b/arcade/camera/camera_2d.py index 549009b3f..a1a03ae4b 100644 --- a/arcade/camera/camera_2d.py +++ b/arcade/camera/camera_2d.py @@ -484,8 +484,8 @@ def point_in_view(self, point: Point2) -> bool: """ # This is unwrapped from standard Vec2 operations, # The construction and garbage collection of the vectors would - # increase this method's cost by ~4x - + # increase this method's cost by ~4x + pos = self.position diff = point[0] - pos[0], point[1] - pos[1] @@ -569,7 +569,6 @@ def projection(self) -> Rect: @projection.setter def projection(self, value: Rect) -> None: - # Unpack and validate if not value: raise ZeroProjectionDimension((f"Projection area is 0, {value.lrbt}")) diff --git a/arcade/future/splash.py b/arcade/future/splash.py index 5f3318fc6..b9dde31fc 100644 --- a/arcade/future/splash.py +++ b/arcade/future/splash.py @@ -21,7 +21,7 @@ class ArcadeSplash(View): dark_mode: If True, the splash screen will be shown in dark mode. (Default False) """ - def __init__(self, view: View, duration: int = 3, dark_mode: bool = False): + def __init__(self, view: View, duration: float = 3.0, dark_mode: bool = False): super().__init__() self._next_view = view self._duration = duration diff --git a/arcade/hitbox/__init__.py b/arcade/hitbox/__init__.py index ab5d304dc..ae79fa3b1 100644 --- a/arcade/hitbox/__init__.py +++ b/arcade/hitbox/__init__.py @@ -6,18 +6,24 @@ from .base import HitBox, HitBoxAlgorithm, RotatableHitBox from .bounding_box import BoundingHitBoxAlgorithm -from .pymunk import PymunkHitBoxAlgorithm from .simple import SimpleHitBoxAlgorithm #: The simple hit box algorithm. algo_simple = SimpleHitBoxAlgorithm() -#: The detailed hit box algorithm. -algo_detailed = PymunkHitBoxAlgorithm() #: The bounding box hit box algorithm. algo_bounding_box = BoundingHitBoxAlgorithm() #: The default hit box algorithm. algo_default = algo_simple +#: The detailed hit box algorithm, if pymunk available. +try: + from .pymunk import PymunkHitBoxAlgorithm + + algo_detailed = PymunkHitBoxAlgorithm() +except ImportError: + algo_detailed = None # type: ignore + print("Warning: pymunk is not installed. PymunkHitBoxAlgorithm will not be available.") + # Temporary functions for backwards compatibility def calculate_hit_box_points_simple(image: Image, *args) -> Point2List: @@ -46,6 +52,7 @@ def calculate_hit_box_points_detailed( How detailed to make the hit box. There's a trade-off in number of points vs. accuracy. """ + assert algo_detailed, "PymunkHitBoxAlgorithm is not available." return algo_detailed.calculate(image, detail=hit_box_detail) diff --git a/pyproject.toml b/pyproject.toml index 515e1b6f6..fd21bcd67 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -86,6 +86,8 @@ version = { attr = "arcade.version.VERSION" } requires = ["setuptools", "wheel"] build-backend = "setuptools.build_meta" +[tool.uv] +prerelease = "allow" [tool.ruff] # --- Description of what we ignore ---