tilemap-parser 4.2.1__py3-none-any.whl → 4.2.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ from __future__ import annotations
18
18
  from pathlib import Path
19
19
  from typing import Dict, List, Optional, Union
20
20
 
21
+ import pygame
21
22
  from pygame import Surface
22
23
 
23
24
  from ..parser.collision import CollisionPolygon, ObjectCollisionData
@@ -31,6 +32,12 @@ class MapObject:
31
32
  A game object loaded from a tilemap, carrying a surface for
32
33
  rendering and collision data for physics.
33
34
 
35
+ All spatial data (``x``, ``y``, ``surface`` size, and collision
36
+ polygon vertices) is pre-scaled by the map's ``render_scale``.
37
+ Units are in *effective* pixels (``render_scale × tile_size``).
38
+ The object is ready for direct use in a game loop that runs in
39
+ effective-pixel space — no additional scaling needed.
40
+
34
41
  Satisfies the :class:`ICollidableObject` protocol so it can be
35
42
  added directly to an :class:`ObjectCollisionManager`.
36
43
 
@@ -89,9 +96,26 @@ def load_map_objects(
89
96
 
90
97
  Iterates every object layer in *tilemap_data*, resolves the
91
98
  corresponding ``.object_collision.json`` from *collision_dir*, and
92
- builds :class:`MapObject` instances with surfaces, owner-local
93
- collision shapes (region offset only; consumers add x/y), and
94
- layer/mask values from the collision regions.
99
+ builds :class:`MapObject` instances with pre-scaled surfaces,
100
+ positions, and collision shapes.
101
+
102
+ **render_scale transparency**
103
+
104
+ All spatial data is automatically scaled by the map's
105
+ ``render_scale`` (from ``tilemap_data.render_scale``):
106
+
107
+ * ``MapObject.x`` / ``MapObject.y`` — raw map coords × ``rs``
108
+ (stored as ``float``; fractional pixel positions are preserved).
109
+ * ``MapObject.surface`` — surface is scaled by ``rs`` via
110
+ :func:`pygame.transform.scale` (no-op when ``rs == 1.0``).
111
+ Raster dimensions are truncated to integers via ``int()``
112
+ to satisfy :func:`pygame.transform.scale` requirements.
113
+ * Collision polygon vertices and ``region_rect`` offsets are
114
+ multiplied by ``rs`` via :meth:`CollisionPolygon.transform`.
115
+
116
+ The returned objects are ready for a game loop that runs in
117
+ effective-pixel space (``render_scale × tile_size``). No
118
+ additional scaling is required by the caller.
95
119
 
96
120
  Collision data is cached per tileset index so the same file is
97
121
  never loaded twice.
@@ -123,6 +147,13 @@ def load_map_objects(
123
147
  continue
124
148
 
125
149
  surf, x, y = surf_x_y
150
+ rs = tilemap_data.render_scale
151
+ x = x * rs
152
+ y = y * rs
153
+
154
+ if rs != 1.0 and surf is not None:
155
+ w, h = surf.get_size()
156
+ surf = pygame.transform.scale(surf, (int(w * rs), int(h * rs)))
126
157
 
127
158
  ttype = obj.ttype
128
159
  if ttype not in loaded_collision:
@@ -142,9 +173,9 @@ def load_map_objects(
142
173
  if not world_shapes:
143
174
  region_layer = region.collision_layer
144
175
  region_mask = region.collision_mask
145
- ox = region.region_rect[0]
146
- oy = region.region_rect[1]
147
- world_shapes.extend(shape.transform(ox, oy) for shape in region.shapes)
176
+ ox = region.region_rect[0] * rs
177
+ oy = region.region_rect[1] * rs
178
+ world_shapes.extend(shape.transform(ox, oy, rs) for shape in region.shapes)
148
179
  if not world_shapes:
149
180
  continue
150
181
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tilemap-parser
3
- Version: 4.2.1
3
+ Version: 4.2.2
4
4
  Summary: Standalone parser/loader for tilemap-editor JSON maps, sprite animations, and collision detection runtime.
5
5
  Author: tilemap parser contributors
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -13,15 +13,15 @@ tilemap_parser/runtime/area_node.py,sha256=gLxpKnO5PumtZ0HzWHl9Osqgp2fzbF2L4ZbNx
13
13
  tilemap_parser/runtime/camera.py,sha256=UXHN0cRvhbiA0soCinu357S5FpynT0cAYENURax4Ti8,5016
14
14
  tilemap_parser/runtime/collision_cache.py,sha256=fMDGPuyRjddL8KjUnn95iGE-RlK-PaGa3Pzh80z0lAg,4751
15
15
  tilemap_parser/runtime/map_loader.py,sha256=jW-C9AdX8bknNEfB-rEY9g5oABvZDTosPJccvIgPf3Y,16278
16
- tilemap_parser/runtime/map_object.py,sha256=98n7-DGnqL3VDIpTUL5k3oMjpBwZmNPqPBYN63mkTvk,6156
16
+ tilemap_parser/runtime/map_object.py,sha256=Sy3tt3OSfot1E2MaxrgfX4I8GlUA5bWPUEHwVJfjBgE,7551
17
17
  tilemap_parser/runtime/object_collision.py,sha256=FgxjTOtSHcjg1dlro9FPt4uAofvIiKXGTlYxT0Orh3U,18960
18
18
  tilemap_parser/runtime/particles.py,sha256=PO-1fwa-BW3FUPSECjvqH7s_4z5zocLzJZTze_1gUbY,18066
19
19
  tilemap_parser/runtime/renderer.py,sha256=vMO8Nfm6d7j6wlGGLxKrnQykdmnwRSExnIKpz9MZRUY,7132
20
20
  tilemap_parser/runtime/tile_collision.py,sha256=tPj9qKg9nbbOpKbAIYJh8QknjRg9oh-dyKdYvOD4QgA,77946
21
21
  tilemap_parser/utils/__init__.py,sha256=GjdWhC__OaDH-eZZkRxYnDzfd_5kTeHKcZ2_F1D3FEQ,621
22
22
  tilemap_parser/utils/geometry.py,sha256=UyZm1TMoUs40xnYmuxS8iD9626D6_Ad2SXa7l_ukg-c,22369
23
- tilemap_parser-4.2.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
24
- tilemap_parser-4.2.1.dist-info/METADATA,sha256=-0nGIb8Ay9XucUFJj59_yu4eOU08wVIz8qyFFDeFRsg,44346
25
- tilemap_parser-4.2.1.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
26
- tilemap_parser-4.2.1.dist-info/top_level.txt,sha256=VOScMmS9EE8Z6kFSJPMwiiFEqpnH2rjLF6cU8M_oFeU,15
27
- tilemap_parser-4.2.1.dist-info/RECORD,,
23
+ tilemap_parser-4.2.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
24
+ tilemap_parser-4.2.2.dist-info/METADATA,sha256=uB7ZmHICQiitm9SjOWcB2Ux60HFcrbGuz_IH7D_nNBc,44346
25
+ tilemap_parser-4.2.2.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
26
+ tilemap_parser-4.2.2.dist-info/top_level.txt,sha256=VOScMmS9EE8Z6kFSJPMwiiFEqpnH2rjLF6cU8M_oFeU,15
27
+ tilemap_parser-4.2.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (82.0.1)
2
+ Generator: setuptools (83.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5