tilemap-parser 3.1.4__tar.gz → 3.1.6__tar.gz
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.
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/PKG-INFO +1 -1
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/pyproject.toml +1 -1
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/parser/animation.py +13 -1
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/animation_player.py +12 -1
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser.egg-info/PKG-INFO +1 -1
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/LICENSE +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/README.md +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/setup.cfg +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/__init__.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/parser/__init__.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/parser/collision.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/parser/collision_loader.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/parser/map_parse.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/__init__.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/collision_cache.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/map_loader.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/object_collision.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/renderer.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/tile_collision.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/utils/__init__.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/utils/geometry.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser.egg-info/SOURCES.txt +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser.egg-info/dependency_links.txt +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser.egg-info/requires.txt +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser.egg-info/top_level.txt +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/tests/test_collision.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/tests/test_geometry.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/tests/test_map_loader.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/tests/test_object_collision.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/tests/test_render_scale.py +0 -0
- {tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/tests/test_tile_collision.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tilemap-parser
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.6
|
|
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
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tilemap-parser"
|
|
7
|
-
version = "3.1.
|
|
7
|
+
version = "3.1.6"
|
|
8
8
|
description = "Standalone parser/loader for tilemap-editor JSON maps, sprite animations, and collision detection runtime."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -97,6 +97,8 @@ class AnimationLibrary:
|
|
|
97
97
|
animations: Dict[str, AnimationClip] = field(default_factory=dict)
|
|
98
98
|
spritesheet_path: Optional[str] = None
|
|
99
99
|
tile_size: Tuple[int, int] = (32, 32)
|
|
100
|
+
grid_offset: Tuple[int, int] = (0, 0)
|
|
101
|
+
trim_transparent: bool = False
|
|
100
102
|
|
|
101
103
|
def get(self, name: str) -> Optional[AnimationClip]:
|
|
102
104
|
return self.animations.get(name)
|
|
@@ -153,13 +155,23 @@ def parse_animation_dict(data: Dict[str, Any]) -> AnimationLibrary:
|
|
|
153
155
|
if tw < 1 or th < 1:
|
|
154
156
|
raise AnimationParseError("tile_size: width and height must be >= 1")
|
|
155
157
|
|
|
158
|
+
grid_offset_raw = root.get("grid_offset", [0, 0])
|
|
159
|
+
if not isinstance(grid_offset_raw, (list, tuple)) or len(grid_offset_raw) != 2:
|
|
160
|
+
raise AnimationParseError("grid_offset: expected [x, y]")
|
|
161
|
+
gox = _coerce_int(grid_offset_raw[0], "grid_offset[0]")
|
|
162
|
+
goy = _coerce_int(grid_offset_raw[1], "grid_offset[1]")
|
|
163
|
+
if gox < 0 or goy < 0:
|
|
164
|
+
raise AnimationParseError("grid_offset: values must be >= 0")
|
|
165
|
+
|
|
156
166
|
animations_raw = _req_dict(root.get("animations", {}), "animations")
|
|
157
167
|
animations: Dict[str, AnimationClip] = {}
|
|
158
168
|
for key, value in animations_raw.items():
|
|
159
169
|
k = str(key)
|
|
160
170
|
animations[k] = _parse_animation(k, _req_dict(value, f"animations[{k!r}]"), f"animations[{k!r}]")
|
|
161
171
|
|
|
162
|
-
|
|
172
|
+
trim_transparent = bool(root.get("trim_transparent", False))
|
|
173
|
+
|
|
174
|
+
return AnimationLibrary(animations=animations, spritesheet_path=spritesheet_path, tile_size=(tw, th), grid_offset=(gox, goy), trim_transparent=trim_transparent)
|
|
163
175
|
|
|
164
176
|
|
|
165
177
|
def parse_animation_json(text: str) -> AnimationLibrary:
|
{tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/animation_player.py
RENAMED
|
@@ -59,7 +59,14 @@ class SpriteAnimationSet:
|
|
|
59
59
|
except pygame.error as e:
|
|
60
60
|
raise AnimationParseError(f"Failed to load image {image_path}: {e}") from e
|
|
61
61
|
|
|
62
|
-
return cls(
|
|
62
|
+
return cls(
|
|
63
|
+
library=library,
|
|
64
|
+
surface=surface,
|
|
65
|
+
warnings=warnings,
|
|
66
|
+
json_path=path,
|
|
67
|
+
grid_offset_x=library.grid_offset[0],
|
|
68
|
+
grid_offset_y=library.grid_offset[1],
|
|
69
|
+
)
|
|
63
70
|
|
|
64
71
|
def get_image(self, variant_id: int, *, copy_surface: bool = True) -> Optional[Surface]:
|
|
65
72
|
tw, th = self.library.tile_size
|
|
@@ -76,6 +83,10 @@ class SpriteAnimationSet:
|
|
|
76
83
|
if not self.surface.get_rect().contains(src):
|
|
77
84
|
return None
|
|
78
85
|
cel = self.surface.subsurface(src)
|
|
86
|
+
if self.library.trim_transparent:
|
|
87
|
+
brect = cel.get_bounding_rect()
|
|
88
|
+
if brect:
|
|
89
|
+
cel = cel.subsurface(brect)
|
|
79
90
|
return cel.copy() if copy_surface else cel
|
|
80
91
|
|
|
81
92
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tilemap-parser
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.6
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser/runtime/object_collision.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tilemap_parser-3.1.4 → tilemap_parser-3.1.6}/src/tilemap_parser.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|