Skip to content

Commit 049f2be

Browse files
committed
data
1 parent b36a4ef commit 049f2be

1 file changed

Lines changed: 12 additions & 17 deletions

File tree

‎pyscroll/data.py‎

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ def process_animation_queue(
8181
8282
Args:
8383
tile_view: Rect representing tiles on the screen
84-
8584
"""
8685
new_tiles = list()
8786

@@ -165,7 +164,6 @@ def prepare_tiles(self, tiles: RectLike) -> None:
165164
166165
Args:
167166
tiles: Reference to the tile view
168-
169167
"""
170168
pass
171169

@@ -174,7 +172,6 @@ def reload_animations(self) -> None:
174172
Reload animation information.
175173
176174
PyscrollDataAdapter.get_animations must be implemented
177-
178175
"""
179176
self._update_time()
180177
self._tracked_gids: set[int] = set()
@@ -209,7 +206,6 @@ def get_tile_image(self, x: int, y: int, l: int) -> Surface:
209206
x: x coordinate
210207
y: y coordinate
211208
l: layer
212-
213209
"""
214210
position: Vector3DInt = (x, y, l)
215211

@@ -245,7 +241,6 @@ def _get_tile_image(self, x: int, y: int, l: int) -> Surface:
245241
x: x coordinate
246242
y: y coordinate
247243
l: layer
248-
249244
"""
250245
raise NotImplementedError
251246

@@ -257,7 +252,6 @@ def _get_tile_image_by_id(self, id: int) -> Any:
257252
258253
Args:
259254
id:
260-
261255
"""
262256
raise NotImplementedError
263257

@@ -280,7 +274,6 @@ def get_animations(self) -> Iterable[tuple[int, list[tuple[int, int]]]]:
280274
This will be something accessible using _get_tile_image_by_id
281275
282276
Duration should be in milliseconds
283-
284277
"""
285278
raise NotImplementedError
286279

@@ -295,11 +288,12 @@ def _get_tile_gid(self, x: int, y: int, l: int) -> Optional[int]:
295288
x: x coordinate
296289
y: y coordinate
297290
l: layer
298-
299291
"""
300292
raise NotImplementedError
301293

302-
def get_tile_images_by_rect(self, rect: RectLike):
294+
def get_tile_images_by_rect(
295+
self, view: RectLike
296+
) -> Iterable[tuple[int, int, int, Surface]]:
303297
"""
304298
Given a 2d area, return generator of tile images inside.
305299
@@ -318,10 +312,9 @@ def get_tile_images_by_rect(self, rect: RectLike):
318312
Not like python 'Range': should include the end index!
319313
320314
Args:
321-
rect: Rect-like object that defines tiles to draw
322-
315+
view: Rect-like object that defines tiles to draw
323316
"""
324-
x1, y1, x2, y2 = rect_to_bb(rect)
317+
x1, y1, x2, y2 = rect_to_bb(view)
325318
for layer in self.visible_tile_layers:
326319
for y, x in product(range(y1, y2 + 1), range(x1, x2 + 1)):
327320
tile = self.get_tile_image(x, y, layer)
@@ -437,13 +430,15 @@ def _get_tile_image(self, x: int, y: int, l: int):
437430
def _get_tile_image_by_id(self, id: int) -> Surface:
438431
return self.tmx.images[id]
439432

440-
def get_tile_images_by_rect(self, rect: RectLike):
433+
def get_tile_images_by_rect(
434+
self, view: RectLike
435+
) -> Iterable[tuple[int, int, int, Surface]]:
441436
def rev(seq: list[int], start: int, stop: int) -> enumerate[int]:
442437
if start < 0:
443438
start = 0
444439
return enumerate(seq[start : stop + 1], start)
445440

446-
x1, y1, x2, y2 = rect_to_bb(rect)
441+
x1, y1, x2, y2 = rect_to_bb(view)
447442
images = self.tmx.images
448443
layers = self.tmx.layers
449444
at = self._animated_tile
@@ -485,7 +480,7 @@ def __init__(self, tile_size: Vector2DInt, normalize: bool = True) -> None:
485480
self.tile_size = tile_size
486481
self._normalize = normalize
487482
self.map_size: tuple[int, int] = (0, 0)
488-
self.maps: list[tuple[PyscrollDataAdapter, pygame.Rect, int]] = []
483+
self.maps: list[tuple[PyscrollDataAdapter, Rect, int]] = []
489484
self._min_x: int = 0
490485
self._min_y: int = 0
491486
self._animation_map: dict[int, AnimationToken] = {}
@@ -574,10 +569,10 @@ def visible_tile_layers(self) -> list[int]:
574569
return sorted(layers)
575570

576571
def get_tile_images_by_rect(
577-
self, view: pygame.Rect
572+
self, view: RectLike
578573
) -> Iterable[tuple[int, int, int, Surface]]:
579574
"""Yield tile images within the view, with adjusted coords and layers."""
580-
view = pygame.Rect(view)
575+
view = Rect(view)
581576
sorted_maps = sorted(self.maps, key=lambda m: m[2]) # sort by z offset
582577

583578
for data, rect, z in sorted_maps:

0 commit comments

Comments
 (0)