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
4 changes: 2 additions & 2 deletions arcade/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

from pathlib import Path

if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 9):
sys.exit("The Arcade Library requires Python 3.9 or higher.")
if sys.version_info[0] < 3 or (sys.version_info[0] == 3 and sys.version_info[1] < 10):
sys.exit("The Arcade Library requires Python 3.10 or higher.")


def configure_logging(level: int | None = None):
Expand Down
5 changes: 3 additions & 2 deletions arcade/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import logging
import os
import time
from typing import TYPE_CHECKING, Sequence
from collections.abc import Sequence
from typing import TYPE_CHECKING

import pyglet
import pyglet.gl as gl
Expand Down Expand Up @@ -36,7 +37,7 @@
MOUSE_BUTTON_MIDDLE = 2
MOUSE_BUTTON_RIGHT = 4

_window: "Window"
_window: Window

__all__ = [
"get_screens",
Expand Down
2 changes: 1 addition & 1 deletion arcade/cache/hit_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def load(self, path: str | Path) -> None:
with gzip.open(path, mode="rb") as fd:
data = json.loads(fd.read())
else:
with open(path, mode="r") as fd:
with open(path) as fd:
data = json.loads(fd.read())

for key, value in data.items():
Expand Down
4 changes: 2 additions & 2 deletions arcade/cache/image_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class ImageDataCache:
"""

def __init__(self):
self._entries: dict[str, "ImageData"] = {}
self._entries: dict[str, ImageData] = {}

def put(self, name: str, image: "ImageData"):
def put(self, name: str, image: ImageData):
"""
Add an image to the cache.

Expand Down
9 changes: 5 additions & 4 deletions arcade/camera/camera_2d.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from collections.abc import Generator
from contextlib import contextmanager
from math import atan2, cos, degrees, radians, sin
from typing import TYPE_CHECKING, Generator
from typing import TYPE_CHECKING

from pyglet.math import Vec2, Vec3
from typing_extensions import Self
Expand Down Expand Up @@ -223,12 +224,12 @@ def from_camera_data(
left, right = projection_data.left, projection_data.right
if projection_data.left == projection_data.right:
raise ZeroProjectionDimension(
(f"projection width is 0 due to equal {left=}and {right=} values")
f"projection width is 0 due to equal {left=}and {right=} values"
)
bottom, top = projection_data.bottom, projection_data.top
if bottom == top:
raise ZeroProjectionDimension(
(f"projection height is 0 due to equal {bottom=}and {top=}")
f"projection height is 0 due to equal {bottom=}and {top=}"
)
near, far = projection_data.near, projection_data.far
if near == far:
Expand Down Expand Up @@ -583,7 +584,7 @@ def projection(self) -> Rect:
def projection(self, value: Rect) -> None:
# Unpack and validate
if not value:
raise ZeroProjectionDimension((f"Projection area is 0, {value.lrbt}"))
raise ZeroProjectionDimension(f"Projection area is 0, {value.lrbt}")

_z = self._camera_data.zoom

Expand Down
3 changes: 2 additions & 1 deletion arcade/camera/data_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
wide usage throughout Arcade's camera code.
"""

from collections.abc import Generator
from contextlib import contextmanager
from typing import Final, Generator, Protocol
from typing import Final, Protocol

from pyglet.math import Vec2, Vec3
from typing_extensions import Self
Expand Down
3 changes: 2 additions & 1 deletion arcade/camera/default.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from collections.abc import Generator
from contextlib import contextmanager
from typing import TYPE_CHECKING, Generator
from typing import TYPE_CHECKING

from pyglet.math import Mat4, Vec2, Vec3
from typing_extensions import Self
Expand Down
3 changes: 2 additions & 1 deletion arcade/camera/orthographic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from collections.abc import Generator
from contextlib import contextmanager
from typing import TYPE_CHECKING, Generator
from typing import TYPE_CHECKING

from pyglet.math import Mat4, Vec2, Vec3
from typing_extensions import Self
Expand Down
3 changes: 2 additions & 1 deletion arcade/camera/perspective.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from __future__ import annotations

from collections.abc import Generator
from contextlib import contextmanager
from math import radians, tan
from typing import TYPE_CHECKING, Generator
from typing import TYPE_CHECKING

from pyglet.math import Mat4, Vec2, Vec3
from typing_extensions import Self
Expand Down
3 changes: 2 additions & 1 deletion arcade/camera/static.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

from collections.abc import Callable, Generator
from contextlib import contextmanager
from typing import TYPE_CHECKING, Callable, Generator
from typing import TYPE_CHECKING

from pyglet.math import Mat4, Vec2, Vec3

Expand Down
3 changes: 2 additions & 1 deletion arcade/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
Contains pre-loaded programs
"""

from collections.abc import Iterable, Sequence
from pathlib import Path
from typing import Any, Iterable, Sequence
from typing import Any

import pyglet
from PIL import Image
Expand Down
2 changes: 1 addition & 1 deletion arcade/easing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Functions used to support easing
"""

from collections.abc import Callable
from dataclasses import dataclass
from math import cos, pi, sin
from typing import Callable

from .math import get_distance

Expand Down
16 changes: 8 additions & 8 deletions arcade/examples/dual_stick_shooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@
def dump_obj(obj):
for key in sorted(vars(obj)):
val = getattr(obj, key)
print("{:30} = {} ({})".format(key, val, type(val).__name__))
print(f"{key:30} = {val} ({type(val).__name__})")


def dump_controller(controller):
print("========== {}".format(controller))
print("Left X {}".format(controller.leftx))
print("Left Y {}".format(controller.lefty))
print("Left Trigger {}".format(controller.lefttrigger))
print("Right X {}".format(controller.rightx))
print("Right Y {}".format(controller.righty))
print("Right Trigger {}".format(controller.righttrigger))
print(f"========== {controller}")
print(f"Left X {controller.leftx}")
print(f"Left Y {controller.lefty}")
print(f"Left Trigger {controller.lefttrigger}")
print(f"Right X {controller.rightx}")
print(f"Right Y {controller.righty}")
print(f"Right Trigger {controller.righttrigger}")
print("========== Extra controller")
dump_obj(controller)
print("========== Extra controller.device")
Expand Down
4 changes: 2 additions & 2 deletions arcade/examples/gl/3d_cube_with_cubes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ def __init__(self, width, height, title):
self.frame = 0

self.fbo1 = self.ctx.framebuffer(
color_attachments=[self.ctx.texture((self.get_size()))],
color_attachments=[self.ctx.texture(self.get_size())],
depth_attachment=self.ctx.depth_texture(self.get_size()),
)
self.fbo2 = self.ctx.framebuffer(
color_attachments=[self.ctx.texture((self.get_size()))],
color_attachments=[self.ctx.texture(self.get_size())],
depth_attachment=self.ctx.depth_texture(self.get_size()),
)

Expand Down
3 changes: 1 addition & 2 deletions arcade/examples/gl/bindless_texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
"""

from array import array
from typing import List
from itertools import cycle

import arcade
Expand Down Expand Up @@ -144,7 +143,7 @@ def __init__(self):
)

self.handles = []
self.textures: List[Texture2D] = []
self.textures: list[Texture2D] = []
# Make a cycle iterator from Arcade's resources (images)
resources = arcade.resources.list_built_in_assets(name="female", extensions=(".png",))
resource_cycle = cycle(resources)
Expand Down
4 changes: 2 additions & 2 deletions arcade/examples/gl/render_indirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ def on_draw(self):
# to prove that partial rendering also works.
# NOTE: These values can be skewed if vsync is enabled
print(
(

f"[{method}] "
f"Pixels written = {self.query.samples_passed // 4}, "
f"Primitives Generated = {self.query.primitives_generated}, "
f"time = {self.query.time_elapsed / 1_000_000_000}s"
)

)

def on_update(self, delta_time: float):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,11 @@ def on_draw(self):
)
print("Indices found:", sprite_indices)
print(
(

f"max(sprite_indices) = {max(sprite_indices)} | "
f"len(self.coins) = {len(self.coins)} | "
f"sprite_indices = {len(sprite_indices)}"
)

)
# Resolve the list of selected sprites and remove them
sprites = [self.coins[int(i)] for i in sprite_indices]
Expand Down
5 changes: 2 additions & 3 deletions arcade/examples/gui/exp_controller_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"""

# TODO: Drag and Drop
from typing import List, Optional

import pyglet.font
from pyglet.event import EVENT_HANDLED
Expand Down Expand Up @@ -75,7 +74,7 @@ class Inventory:
"""

def __init__(self, capacity: int):
self._items: List[Item | None] = [None for _ in range(capacity)]
self._items: list[Item | None] = [None for _ in range(capacity)]
self.capacity = capacity

def add(self, item: Item):
Expand Down Expand Up @@ -352,7 +351,7 @@ def __init__(self, inventory: Inventory, **kwargs):
# init controller support
self.detect_focusable_widgets()

def on_event(self, event: UIEvent) -> Optional[bool]:
def on_event(self, event: UIEvent) -> bool | None:
if isinstance(event, UIControllerButtonPressEvent):
if event.button == "b":
self.set_focus(self.close_button)
Expand Down
3 changes: 1 addition & 2 deletions arcade/examples/gui/exp_controller_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
python -m arcade.examples.gui.exp_controller_support
"""

from typing import Optional

import arcade
from arcade import Texture
Expand Down Expand Up @@ -115,7 +114,7 @@ def input_prompts(cls, event: UIControllerEvent) -> Texture | None:

return None

def on_event(self, event: UIEvent) -> Optional[bool]:
def on_event(self, event: UIEvent) -> bool | None:
if isinstance(event, UIControllerEvent):
input_texture = self.input_prompts(event)

Expand Down
3 changes: 1 addition & 2 deletions arcade/examples/gui/exp_controller_support_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
python -m arcade.examples.gui.exp_controller_support_grid
"""

from typing import Dict, Tuple

import arcade
from arcade.examples.gui.exp_controller_support import ControllerIndicator
Expand All @@ -27,7 +26,7 @@ class FocusableButton(UIFocusable, UIFlatButton):
pass


def setup_grid_focus_transition(grid: Dict[Tuple[int, int], UIWidget]):
def setup_grid_focus_transition(grid: dict[tuple[int, int], UIWidget]):
"""Setup focus transition in grid.

Connect focus transition between `Focusable` in grid.
Expand Down
4 changes: 2 additions & 2 deletions arcade/examples/particle_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ def __init__(self):

def next_emitter(self, _time_delta):
self.emitter_factory_id = (self.emitter_factory_id + 1) % len(self.factories)
print("Changing emitter to {}".format(self.emitter_factory_id))
print(f"Changing emitter to {self.emitter_factory_id}")
self.emitter_timeout = 0
self.label, self.emitter = self.factories[self.emitter_factory_id]()

Expand All @@ -827,7 +827,7 @@ def on_draw(self):
self.clear()
arcade.draw_sprite(self.obj)
if self.label:
arcade.draw_text("#{} {}".format(self.emitter_factory_id, self.label),
arcade.draw_text(f"#{self.emitter_factory_id} {self.label}",
WINDOW_WIDTH / 2, WINDOW_HEIGHT - 25,
arcade.color.PALE_GOLD, 20, width=WINDOW_WIDTH,
anchor_x="center")
Expand Down
15 changes: 7 additions & 8 deletions arcade/examples/sprite_health.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
python -m arcade.examples.sprite_health
"""
import math
from typing import Tuple

import arcade
from arcade.types import Color
Expand Down Expand Up @@ -102,13 +101,13 @@ def __init__(
self,
owner: Player,
sprite_list: arcade.SpriteList,
position: Tuple[float, float] = (0, 0),
position: tuple[float, float] = (0, 0),
full_color: Color = arcade.color.GREEN,
background_color: Color = arcade.color.BLACK,
width: int = 100,
height: int = 4,
border_size: int = 4,
scale: Tuple[float, float] = (1.0, 1.0),
scale: tuple[float, float] = (1.0, 1.0),
) -> None:
# Store the reference to the owner and the sprite list
self.owner: Player = owner
Expand All @@ -120,7 +119,7 @@ def __init__(
self._center_x: float = 0.0
self._center_y: float = 0.0
self._fullness: float = 0.0
self._scale: Tuple[float, float] = (1.0, 1.0)
self._scale: tuple[float, float] = (1.0, 1.0)

# Create the boxes needed to represent the indicator bar
self._background_box: arcade.SpriteSolidColor = arcade.SpriteSolidColor(
Expand Down Expand Up @@ -220,12 +219,12 @@ def fullness(self, new_fullness: float) -> None:
self.full_box.left = self._center_x - (self._bar_width / 2) * self.scale[0]

@property
def position(self) -> Tuple[float, float]:
def position(self) -> tuple[float, float]:
"""Returns the current position of the bar."""
return self._center_x, self._center_y

@position.setter
def position(self, new_position: Tuple[float, float]) -> None:
def position(self, new_position: tuple[float, float]) -> None:
"""Sets the new position of the bar."""
# Check if the position has changed. If so, change the bar's position
if new_position != self.position:
Expand All @@ -237,12 +236,12 @@ def position(self, new_position: Tuple[float, float]) -> None:
self.full_box.left = self._center_x - (self._bar_width / 2) * self.scale[0]

@property
def scale(self) -> Tuple[float, float]:
def scale(self) -> tuple[float, float]:
"""Returns the scale of the bar."""
return self._scale

@scale.setter
def scale(self, value: Tuple[float, float]) -> None:
def scale(self, value: tuple[float, float]) -> None:
"""Sets the new scale of the bar."""
# Check if the scale has changed. If so, change the bar's scale
if value != self.scale:
Expand Down
Loading
Loading