|
8 | 8 | import bisect |
9 | 9 | import pygame |
10 | 10 |
|
11 | | -from typing import Optional |
| 11 | +from typing import Optional, Union |
12 | 12 |
|
13 | 13 |
|
14 | 14 | class EntityAnim: |
@@ -48,7 +48,7 @@ def __init__(self, anim_path: str, loop: bool = True) -> None: |
48 | 48 | self._started_at: int = 0 |
49 | 49 |
|
50 | 50 | self._scaled: Optional[pygame.Surface] = None |
51 | | - self._scaled_key: Optional[tuple[int, int, int]] = None |
| 51 | + self._scaled_key: Optional[tuple[int, float, float]] = None |
52 | 52 |
|
53 | 53 | self.set_image(anim_path) |
54 | 54 |
|
@@ -139,19 +139,19 @@ def _current_index(self) -> int: |
139 | 139 |
|
140 | 140 | return bisect.bisect_right(self._starts, elapsed) - 1 |
141 | 141 |
|
142 | | - def draw(self, surface: pygame.Surface, rect: pygame.Rect) -> None: |
| 142 | + def draw(self, surface: pygame.Surface, rect: Union[pygame.Rect, pygame.FRect]) -> None: |
143 | 143 | """ |
144 | 144 | Draw the current frame of the animation scaled to ``rect`` onto ``surface``. |
145 | 145 |
|
146 | 146 | Args: |
147 | 147 | surface (pygame.Surface): surface to draw onto |
148 | | - rect (pygame.Rect): rect to scale image to |
| 148 | + rect (pygame.Rect | pygame.FRect): rect to scale image to |
149 | 149 | """ |
150 | 150 |
|
151 | 151 | assert self.frames, "EntityAnim.frames was not initialized" # nosec B101 |
152 | 152 |
|
153 | 153 | index: int = self._current_index() |
154 | | - key: tuple[int, int, int] = (index, rect.width, rect.height) |
| 154 | + key: tuple[int, float, float] = (index, rect.width, rect.height) |
155 | 155 |
|
156 | 156 | if key != self._scaled_key or self._scaled is None: |
157 | 157 | self._scaled = pygame.transform.scale(self.frames[index], (rect.width, rect.height)) |
|
0 commit comments