tilemap-parser 6.0.0__tar.gz → 6.0.1__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-6.0.0/src/tilemap_parser.egg-info → tilemap_parser-6.0.1}/PKG-INFO +2 -1
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/README.md +1 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/pypi-readme.md +1 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/pyproject.toml +1 -1
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/collision.py +10 -13
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/grounded.py +2 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/platformer.py +12 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/queries.py +23 -3
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/rpg.py +2 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/runner.py +17 -4
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/slide.py +2 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/types.py +11 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/world.py +5 -1
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1/src/tilemap_parser.egg-info}/PKG-INFO +2 -1
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser.egg-info/SOURCES.txt +1 -0
- tilemap_parser-6.0.1/tests/test_docs_snippets.py +153 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_ground_info.py +148 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/LICENSE +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/setup.cfg +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/__init__.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/__init__.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/animation.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/collision_loader.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/map_parse.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/node_parse.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/particle.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/tileanim.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/parser/tmx_converter.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/__init__.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/animation_player.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/area_node.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/body.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/camera.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/collision/__init__.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/collision/hit.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/collision/manager.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/collision/shapes.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/collision_cache.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/map_loader.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/map_object.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/__init__.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/navigation/__init__.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/navigation/nav_grid.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/navigation/path_follower.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/navigation/pathfinder.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/particles.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/polygon_query.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/protocols.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/renderer.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/utils/__init__.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/utils/geometry.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser.egg-info/dependency_links.txt +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser.egg-info/requires.txt +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser.egg-info/top_level.txt +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_background_layer.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_body.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_camera.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_character_flip.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_collision.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_collision_debug.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_geometry.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_gid_collision.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_gid_override.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_gid_routing.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_integration_animation.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_integration_collision.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_integration_map_loader.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_layer_union.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_map_loader.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_map_object.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_map_offset.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_move_grounded.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_navigation.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_object_animation.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_object_collision.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_object_surfaces.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_particle_emitter.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_render_scale.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_tile_anim_clips.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_tile_collision.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_tile_flips.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_tile_layer_renderer_y_sort.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_tile_layers.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_tileset_surfaces.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_tmx_converter.py +0 -0
- {tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/tests/test_v6_contract.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tilemap-parser
|
|
3
|
-
Version: 6.0.
|
|
3
|
+
Version: 6.0.1
|
|
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: MIT
|
|
@@ -58,6 +58,7 @@ mist = ParticleField(
|
|
|
58
58
|
|
|
59
59
|
- **Map parsing** — tilemaps, layers, objects, and autotile data from JSON
|
|
60
60
|
- **Collision** — tile-based (`CollisionRunner`) and object-to-object (`ObjectCollisionManager`) with rect, circle, capsule, and polygon shapes
|
|
61
|
+
- **Ground tile identity** — `CollisionResult.ground_tile` / `ground_tile_id` report which tile supports a grounded sprite; custom tile properties are preserved on `TileCollisionData.properties`
|
|
61
62
|
- **Physics** — `PhysicsWorld` with static/kinematic `Body` solids and one-way platforms
|
|
62
63
|
- **Particles** — wrapped continuous fields (`ParticleField`, `FOG_PROFILE`), burst emitters, alpha fades, and batch rendering (`SpriteBatchRenderer`)
|
|
63
64
|
- **Pathfinding** — A* `Pathfinder` over eroded `NavGrid`s
|
|
@@ -10,6 +10,7 @@ Standalone parser/loader for tilemap-editor JSON maps, sprite animations, and co
|
|
|
10
10
|
- **Animation**: Frame-based sprite animation with `AnimationPlayer`
|
|
11
11
|
- **Particle system**: Configurable particle emitters with shapes, color transitions, alpha fades, gravity, and batch rendering with `ParticleSystem` + `SpriteBatchRenderer`
|
|
12
12
|
- **Collision (tile-based)**: Polygon collision detection for tilemaps with slide, platformer, and RPG movement modes via `CollisionRunner`
|
|
13
|
+
- **Ground tile identity**: `CollisionResult.ground_tile` and `ground_tile_id` report the tile supporting a grounded sprite, with custom tile properties preserved on `TileCollisionData.properties`
|
|
13
14
|
- **Collision (object-to-object)**: Spatial-grid mixed-shape collision detection (rect, circle, capsule, polygon) with layer filtering via `ObjectCollisionManager`
|
|
14
15
|
- **Capsule support**: Full capsule collision against all shape types
|
|
15
16
|
- **Hit helpers**: `CollisionHit.resolve()`, `involves()`, `other()` for ergonomic separation
|
|
@@ -32,6 +32,7 @@ mist = ParticleField(
|
|
|
32
32
|
|
|
33
33
|
- **Map parsing** — tilemaps, layers, objects, and autotile data from JSON
|
|
34
34
|
- **Collision** — tile-based (`CollisionRunner`) and object-to-object (`ObjectCollisionManager`) with rect, circle, capsule, and polygon shapes
|
|
35
|
+
- **Ground tile identity** — `CollisionResult.ground_tile` / `ground_tile_id` report which tile supports a grounded sprite; custom tile properties are preserved on `TileCollisionData.properties`
|
|
35
36
|
- **Physics** — `PhysicsWorld` with static/kinematic `Body` solids and one-way platforms
|
|
36
37
|
- **Particles** — wrapped continuous fields (`ParticleField`, `FOG_PROFILE`), burst emitters, alpha fades, and batch rendering (`SpriteBatchRenderer`)
|
|
37
38
|
- **Pathfinding** — A* `Pathfinder` over eroded `NavGrid`s
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "tilemap-parser"
|
|
7
|
-
version = "6.0.
|
|
7
|
+
version = "6.0.1"
|
|
8
8
|
description = "Standalone parser/loader for tilemap-editor JSON maps, sprite animations, and collision detection runtime."
|
|
9
9
|
readme = "pypi-readme.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -63,9 +63,9 @@ class CollisionPolygon:
|
|
|
63
63
|
class TileCollisionData:
|
|
64
64
|
tile_id: int
|
|
65
65
|
shapes: list[CollisionPolygon] = field(default_factory=list)
|
|
66
|
-
# Mutual layer/mask agreement required; defaults collide with everything.
|
|
67
66
|
collision_layer: int = 1
|
|
68
67
|
collision_mask: int = 0xFFFFFFFF
|
|
68
|
+
properties: dict[str, Any] = field(default_factory=dict)
|
|
69
69
|
|
|
70
70
|
def has_collision(self) -> bool:
|
|
71
71
|
return any(shape.is_valid() for shape in self.shapes)
|
|
@@ -111,6 +111,7 @@ class TilesetCollision:
|
|
|
111
111
|
shapes=data.shapes[:],
|
|
112
112
|
collision_layer=data.collision_layer,
|
|
113
113
|
collision_mask=data.collision_mask,
|
|
114
|
+
properties=dict(data.properties),
|
|
114
115
|
)
|
|
115
116
|
return cls(
|
|
116
117
|
tileset_name="merged",
|
|
@@ -276,9 +277,7 @@ class ObjectCollisionRegionData:
|
|
|
276
277
|
def has_collision(self) -> bool:
|
|
277
278
|
return any(shape.is_valid() for shape in self.shapes)
|
|
278
279
|
|
|
279
|
-
def get_world_shapes(
|
|
280
|
-
self, world_x: float, world_y: float
|
|
281
|
-
) -> list[CollisionPolygon]:
|
|
280
|
+
def get_world_shapes(self, world_x: float, world_y: float) -> list[CollisionPolygon]:
|
|
282
281
|
ox = world_x + self.region_rect[0]
|
|
283
282
|
oy = world_y + self.region_rect[1]
|
|
284
283
|
return [shape.transform(ox, oy) for shape in self.shapes]
|
|
@@ -298,6 +297,7 @@ class ObjectCollisionData:
|
|
|
298
297
|
|
|
299
298
|
|
|
300
299
|
def parse_tileset_collision(data: JsonDict) -> TilesetCollision:
|
|
300
|
+
"""Parse tileset collision JSON data into a TilesetCollision model."""
|
|
301
301
|
try:
|
|
302
302
|
tileset_name = data["tileset_name"]
|
|
303
303
|
tile_size_raw = data["tile_size"]
|
|
@@ -323,10 +323,13 @@ def parse_tileset_collision(data: JsonDict) -> TilesetCollision:
|
|
|
323
323
|
shapes=shapes,
|
|
324
324
|
collision_layer=int(props.get("collision_layer", 1)),
|
|
325
325
|
collision_mask=int(props.get("collision_mask", 0xFFFFFFFF)),
|
|
326
|
+
properties=dict(props),
|
|
326
327
|
)
|
|
327
328
|
|
|
328
329
|
return TilesetCollision(
|
|
329
|
-
tileset_name=tileset_name,
|
|
330
|
+
tileset_name=tileset_name,
|
|
331
|
+
tile_size=tile_size,
|
|
332
|
+
tiles=tiles,
|
|
330
333
|
)
|
|
331
334
|
except (KeyError, ValueError, TypeError) as e:
|
|
332
335
|
raise CollisionParseError(f"Invalid tileset collision data: {e}") from e
|
|
@@ -334,11 +337,7 @@ def parse_tileset_collision(data: JsonDict) -> TilesetCollision:
|
|
|
334
337
|
|
|
335
338
|
def parse_character_collision(data: JsonDict, render_scale: float = 1.0) -> CharacterCollision:
|
|
336
339
|
"""Non-finite/non-positive scale raises; shape scaled unless 1.0."""
|
|
337
|
-
if (
|
|
338
|
-
not isinstance(render_scale, (int, float))
|
|
339
|
-
or not math.isfinite(render_scale)
|
|
340
|
-
or render_scale <= 0
|
|
341
|
-
):
|
|
340
|
+
if not isinstance(render_scale, (int, float)) or not math.isfinite(render_scale) or render_scale <= 0:
|
|
342
341
|
raise CollisionParseError(f"render_scale must be finite and > 0, got {render_scale!r}")
|
|
343
342
|
try:
|
|
344
343
|
name = data["name"]
|
|
@@ -366,9 +365,7 @@ def parse_character_collision(data: JsonDict, render_scale: float = 1.0) -> Char
|
|
|
366
365
|
raise CollisionParseError("Polygon shape missing 'vertices' field")
|
|
367
366
|
vertices = [tuple(v) for v in vertices_raw]
|
|
368
367
|
if len(vertices) < 3:
|
|
369
|
-
raise CollisionParseError(
|
|
370
|
-
f"Polygon must have at least 3 vertices, got {len(vertices)}"
|
|
371
|
-
)
|
|
368
|
+
raise CollisionParseError(f"Polygon must have at least 3 vertices, got {len(vertices)}")
|
|
372
369
|
one_way = shape_data.get("one_way", False)
|
|
373
370
|
shape = CollisionPolygon(vertices=vertices, one_way=one_way)
|
|
374
371
|
else:
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/platformer.py
RENAMED
|
@@ -39,6 +39,8 @@ def move_platformer(
|
|
|
39
39
|
result.slide_vector = None
|
|
40
40
|
result.ground_angle = None
|
|
41
41
|
result.ground_normal = None
|
|
42
|
+
result.ground_tile = None
|
|
43
|
+
result.ground_tile_id = None
|
|
42
44
|
result.final_x = sprite.x
|
|
43
45
|
result.final_y = sprite.y
|
|
44
46
|
|
|
@@ -284,6 +286,8 @@ def move_platformer_with_slide(
|
|
|
284
286
|
result.slide_vector = None
|
|
285
287
|
result.ground_angle = None
|
|
286
288
|
result.ground_normal = None
|
|
289
|
+
result.ground_tile = None
|
|
290
|
+
result.ground_tile_id = None
|
|
287
291
|
result.final_x = sprite.x
|
|
288
292
|
result.final_y = sprite.y
|
|
289
293
|
|
|
@@ -484,8 +488,16 @@ def move_platformer_with_slide(
|
|
|
484
488
|
if result.on_ground and support_info is not None:
|
|
485
489
|
result.ground_angle = support_info.angle
|
|
486
490
|
result.ground_normal = support_info.normal
|
|
491
|
+
result.ground_tile = (
|
|
492
|
+
(support_info.tile_x, support_info.tile_y)
|
|
493
|
+
if support_info.tile_x is not None
|
|
494
|
+
else None
|
|
495
|
+
)
|
|
496
|
+
result.ground_tile_id = support_info.tile_id
|
|
487
497
|
else:
|
|
488
498
|
result.ground_angle = None
|
|
489
499
|
result.ground_normal = None
|
|
500
|
+
result.ground_tile = None
|
|
501
|
+
result.ground_tile_id = None
|
|
490
502
|
return result
|
|
491
503
|
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/queries.py
RENAMED
|
@@ -49,6 +49,13 @@ def _literal_entry_data(
|
|
|
49
49
|
|
|
50
50
|
def _iter_tile_datas(world, tileset_collision: TilesetCollision, cell: object, sprite=None):
|
|
51
51
|
"""Flip-aware datas for every stacked entry; unioned, layer/mask-filtered."""
|
|
52
|
+
for data, _gid in _iter_tile_entries(world, tileset_collision, cell, sprite):
|
|
53
|
+
yield data
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _iter_tile_entries(world, tileset_collision: TilesetCollision, cell: object, sprite=None):
|
|
57
|
+
"""Flip-aware ``(data, gid)`` for every stacked entry; gid is as stored
|
|
58
|
+
in the cell; layer/mask-filtered."""
|
|
52
59
|
from ..world import iter_cell_entries
|
|
53
60
|
|
|
54
61
|
if world is not None:
|
|
@@ -58,7 +65,7 @@ def _iter_tile_datas(world, tileset_collision: TilesetCollision, cell: object, s
|
|
|
58
65
|
continue
|
|
59
66
|
if sprite is not None and not should_collide(sprite, data):
|
|
60
67
|
continue
|
|
61
|
-
yield data
|
|
68
|
+
yield data, entry[0]
|
|
62
69
|
else:
|
|
63
70
|
for entry in iter_cell_entries(cell):
|
|
64
71
|
data = _literal_entry_data(tileset_collision, entry)
|
|
@@ -66,7 +73,7 @@ def _iter_tile_datas(world, tileset_collision: TilesetCollision, cell: object, s
|
|
|
66
73
|
continue
|
|
67
74
|
if sprite is not None and not should_collide(sprite, data):
|
|
68
75
|
continue
|
|
69
|
-
yield data
|
|
76
|
+
yield data, entry[0]
|
|
70
77
|
|
|
71
78
|
|
|
72
79
|
def _collides_at(
|
|
@@ -296,12 +303,15 @@ def _find_walkable_ground_info(
|
|
|
296
303
|
min_upness = math.cos(math.radians(self.max_walk_angle))
|
|
297
304
|
|
|
298
305
|
best: GroundInfo | None = None
|
|
306
|
+
best_tile_x: int | None = None
|
|
307
|
+
best_tile_y: int | None = None
|
|
308
|
+
best_tile_id: int | None = None
|
|
299
309
|
for tile_y in range(min_tile_y, max_tile_y + 1):
|
|
300
310
|
for tile_x in range(min_tile_x, max_tile_x + 1):
|
|
301
311
|
cell = tile_map.get((tile_x, tile_y))
|
|
302
312
|
if cell is None:
|
|
303
313
|
continue
|
|
304
|
-
for tile_data in
|
|
314
|
+
for tile_data, tile_gid in _iter_tile_entries(world, tileset_collision, cell, sprite):
|
|
305
315
|
ox = tile_x * tw
|
|
306
316
|
oy = tile_y * th
|
|
307
317
|
for poly in tile_data.shapes:
|
|
@@ -342,6 +352,9 @@ def _find_walkable_ground_info(
|
|
|
342
352
|
normal=(nx, ny),
|
|
343
353
|
angle=_angle_from_normal(nx, ny),
|
|
344
354
|
)
|
|
355
|
+
best_tile_x = tile_x
|
|
356
|
+
best_tile_y = tile_y
|
|
357
|
+
best_tile_id = tile_gid
|
|
345
358
|
if world is not None:
|
|
346
359
|
for body in world.bodies:
|
|
347
360
|
if body is sprite:
|
|
@@ -356,6 +369,13 @@ def _find_walkable_ground_info(
|
|
|
356
369
|
continue
|
|
357
370
|
if best is None or ground_y < best.y:
|
|
358
371
|
best = GroundInfo(y=ground_y, normal=(0.0, -1.0), angle=0.0)
|
|
372
|
+
best_tile_x = None
|
|
373
|
+
best_tile_y = None
|
|
374
|
+
best_tile_id = None
|
|
375
|
+
if best is not None:
|
|
376
|
+
best.tile_x = best_tile_x
|
|
377
|
+
best.tile_y = best_tile_y
|
|
378
|
+
best.tile_id = best_tile_id
|
|
359
379
|
return best
|
|
360
380
|
|
|
361
381
|
|
|
@@ -60,7 +60,7 @@ class CollisionRunner:
|
|
|
60
60
|
self._strict: bool = False
|
|
61
61
|
self._world: PhysicsWorld | None = None
|
|
62
62
|
|
|
63
|
-
# Reusable result object
|
|
63
|
+
# Reusable result object, must reset fields before each use
|
|
64
64
|
self._result = CollisionResult()
|
|
65
65
|
|
|
66
66
|
def attach(self, world: PhysicsWorld | None) -> None:
|
|
@@ -73,6 +73,7 @@ class CollisionRunner:
|
|
|
73
73
|
self._eff_th = max(1, int(self.tile_size[1] * self.render_scale))
|
|
74
74
|
|
|
75
75
|
def detach(self) -> None:
|
|
76
|
+
"""Detach the current PhysicsWorld reference."""
|
|
76
77
|
self._world = None
|
|
77
78
|
|
|
78
79
|
def _resolve_world(self, world: PhysicsWorld | None) -> PhysicsWorld | None:
|
|
@@ -98,6 +99,7 @@ class CollisionRunner:
|
|
|
98
99
|
return runner
|
|
99
100
|
|
|
100
101
|
def get_tile_at(self, world_x: float, world_y: float) -> tuple[int, int]:
|
|
102
|
+
"""Convert world coordinates into integer tile cell coordinates (col, row)."""
|
|
101
103
|
tile_x = int(world_x // self._eff_tw)
|
|
102
104
|
tile_y = int(world_y // self._eff_th)
|
|
103
105
|
return (tile_x, tile_y)
|
|
@@ -176,7 +178,11 @@ class CollisionRunner:
|
|
|
176
178
|
"""
|
|
177
179
|
if self.mode == MovementMode.SLIDE:
|
|
178
180
|
return self.move_and_slide(
|
|
179
|
-
sprite,
|
|
181
|
+
sprite,
|
|
182
|
+
tileset_collision,
|
|
183
|
+
tile_map,
|
|
184
|
+
delta_x,
|
|
185
|
+
delta_y,
|
|
180
186
|
slope_slide=kwargs.get("slope_slide", False),
|
|
181
187
|
world=kwargs.get("world"),
|
|
182
188
|
)
|
|
@@ -193,14 +199,21 @@ class CollisionRunner:
|
|
|
193
199
|
)
|
|
194
200
|
elif self.mode == MovementMode.GROUNDED:
|
|
195
201
|
return self.move_grounded(
|
|
196
|
-
sprite,
|
|
202
|
+
sprite,
|
|
203
|
+
tileset_collision,
|
|
204
|
+
tile_map,
|
|
205
|
+
dt,
|
|
197
206
|
velocity=kwargs.get("velocity"),
|
|
198
207
|
world=kwargs.get("world"),
|
|
199
208
|
one_way=kwargs.get("one_way", "solid"),
|
|
200
209
|
)
|
|
201
210
|
elif self.mode == MovementMode.RPG:
|
|
202
211
|
return self.move_rpg(
|
|
203
|
-
sprite,
|
|
212
|
+
sprite,
|
|
213
|
+
tileset_collision,
|
|
214
|
+
tile_map,
|
|
215
|
+
delta_x,
|
|
216
|
+
delta_y,
|
|
204
217
|
world=kwargs.get("world"),
|
|
205
218
|
)
|
|
206
219
|
|
|
@@ -21,11 +21,18 @@ class GroundInfo:
|
|
|
21
21
|
Normal wins; ``angle`` follows it: ``0.0`` = flat, positive rises
|
|
22
22
|
toward ``+X`` (screen coords, ``+Y`` down). Bodies read flat
|
|
23
23
|
``(0.0, -1.0)`` / ``0.0``.
|
|
24
|
+
|
|
25
|
+
Tile identity of the winning support (body support reads ``None``):
|
|
26
|
+
``tile_x`` / ``tile_y`` are cell coords, ``tile_id`` is the gid as
|
|
27
|
+
stored in the cell.
|
|
24
28
|
"""
|
|
25
29
|
|
|
26
30
|
y: float = 0.0
|
|
27
31
|
normal: Vector2 = (0.0, -1.0)
|
|
28
32
|
angle: float = 0.0
|
|
33
|
+
tile_x: int | None = None
|
|
34
|
+
tile_y: int | None = None
|
|
35
|
+
tile_id: int | None = None
|
|
29
36
|
|
|
30
37
|
|
|
31
38
|
@dataclass
|
|
@@ -41,3 +48,7 @@ class CollisionResult:
|
|
|
41
48
|
slide_vector: Vector2 | None = None
|
|
42
49
|
ground_angle: float | None = None
|
|
43
50
|
ground_normal: Vector2 | None = None
|
|
51
|
+
# Tile identity underfoot from the winning support; None when
|
|
52
|
+
# airborne or supported by a body.
|
|
53
|
+
ground_tile: tuple[int, int] | None = None
|
|
54
|
+
ground_tile_id: int | None = None
|
|
@@ -57,7 +57,7 @@ def flipped_data(
|
|
|
57
57
|
flags: int,
|
|
58
58
|
tile_size: Tuple[float, float],
|
|
59
59
|
) -> TileCollisionData:
|
|
60
|
-
"""Same object when flags == 0; preserves one_way/layer/mask."""
|
|
60
|
+
"""Same object when flags == 0; preserves one_way/layer/mask/properties."""
|
|
61
61
|
if not flags:
|
|
62
62
|
return base
|
|
63
63
|
return TileCollisionData(
|
|
@@ -71,6 +71,7 @@ def flipped_data(
|
|
|
71
71
|
],
|
|
72
72
|
collision_layer=base.collision_layer,
|
|
73
73
|
collision_mask=base.collision_mask,
|
|
74
|
+
properties=base.properties,
|
|
74
75
|
)
|
|
75
76
|
|
|
76
77
|
|
|
@@ -245,13 +246,16 @@ class PhysicsWorld:
|
|
|
245
246
|
return self.tileset_collision.tiles.get(tile_id)
|
|
246
247
|
|
|
247
248
|
def has_collision_gid(self, tile_id: int) -> bool:
|
|
249
|
+
"""Return True if the resolved collision data for tile_id defines solid collision shapes."""
|
|
248
250
|
data = self.resolve_collision(tile_id)
|
|
249
251
|
return data is not None and data.has_collision()
|
|
250
252
|
|
|
251
253
|
def tile_ids_at(self, pos: Tuple[int, int]) -> Tuple[int, ...]:
|
|
254
|
+
"""Return a tuple of all tile IDs stacked at the given cell coordinates."""
|
|
252
255
|
return tuple(gid for gid, _flags in iter_cell_entries(self.tile_map.get(tuple(pos))))
|
|
253
256
|
|
|
254
257
|
def tile_entries_at(self, pos: Tuple[int, int]) -> TileCell:
|
|
258
|
+
"""Return stacked (tile_id, flags) entries at the given cell coordinates."""
|
|
255
259
|
return iter_cell_entries(self.tile_map.get(tuple(pos)))
|
|
256
260
|
|
|
257
261
|
def resolve_stack_entry(self, entry: StackEntry) -> Optional[TileCollisionData]:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tilemap-parser
|
|
3
|
-
Version: 6.0.
|
|
3
|
+
Version: 6.0.1
|
|
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: MIT
|
|
@@ -58,6 +58,7 @@ mist = ParticleField(
|
|
|
58
58
|
|
|
59
59
|
- **Map parsing** — tilemaps, layers, objects, and autotile data from JSON
|
|
60
60
|
- **Collision** — tile-based (`CollisionRunner`) and object-to-object (`ObjectCollisionManager`) with rect, circle, capsule, and polygon shapes
|
|
61
|
+
- **Ground tile identity** — `CollisionResult.ground_tile` / `ground_tile_id` report which tile supports a grounded sprite; custom tile properties are preserved on `TileCollisionData.properties`
|
|
61
62
|
- **Physics** — `PhysicsWorld` with static/kinematic `Body` solids and one-way platforms
|
|
62
63
|
- **Particles** — wrapped continuous fields (`ParticleField`, `FOG_PROFILE`), burst emitters, alpha fades, and batch rendering (`SpriteBatchRenderer`)
|
|
63
64
|
- **Pathfinding** — A* `Pathfinder` over eroded `NavGrid`s
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"""Executable documentation: cookbook snippets.
|
|
2
|
+
|
|
3
|
+
Every snippet in webdocs/src/snippets/cookbook.json runs against a
|
|
4
|
+
generated fixture map in a temporary working directory, so the documented
|
|
5
|
+
access patterns fail CI as soon as the API they show changes.
|
|
6
|
+
|
|
7
|
+
Fixture layout, shared by all snippets (cwd is the tmp dir):
|
|
8
|
+
data/map.json tile layer + object layer
|
|
9
|
+
data/collision/ground.collision.json polygons + custom tile properties
|
|
10
|
+
assets/tileset.png 32x16 sheet, two 16x16 cells
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import json
|
|
14
|
+
import sys
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
|
|
17
|
+
import pygame
|
|
18
|
+
import pytest
|
|
19
|
+
|
|
20
|
+
sys.path.insert(0, str(Path(__file__).parent.parent / "src"))
|
|
21
|
+
|
|
22
|
+
from tilemap_parser import load_map # noqa: E402
|
|
23
|
+
|
|
24
|
+
ROOT = Path(__file__).parent.parent
|
|
25
|
+
SNIPPETS = json.loads(
|
|
26
|
+
(ROOT / "webdocs" / "src" / "snippets" / "cookbook.json").read_text()
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
MAP_PAYLOAD = {
|
|
30
|
+
"meta": {
|
|
31
|
+
"tile_size": "16;16",
|
|
32
|
+
"map_size": "4;4",
|
|
33
|
+
"initial_map_size": "4;4",
|
|
34
|
+
"render_scale": 1,
|
|
35
|
+
"scroll": "0;0",
|
|
36
|
+
"version": "1.1",
|
|
37
|
+
},
|
|
38
|
+
"resources": {"tilesets": [{"path": "../assets/tileset.png", "type": "object"}]},
|
|
39
|
+
"project_state": {"rules": [], "groups": []},
|
|
40
|
+
"data": {
|
|
41
|
+
"layers": [
|
|
42
|
+
{
|
|
43
|
+
"name": "Terrain",
|
|
44
|
+
"type": "tile",
|
|
45
|
+
"visible": True,
|
|
46
|
+
"locked": False,
|
|
47
|
+
"opacity": 1.0,
|
|
48
|
+
"z_index": 0,
|
|
49
|
+
"tiles": {
|
|
50
|
+
"0;0": {
|
|
51
|
+
"pos": "0;0",
|
|
52
|
+
"ttype": 0,
|
|
53
|
+
"variant": 1,
|
|
54
|
+
"properties": {"surface": "stone"},
|
|
55
|
+
},
|
|
56
|
+
"1;0": {
|
|
57
|
+
"pos": "1;0",
|
|
58
|
+
"ttype": 0,
|
|
59
|
+
"variant": 0,
|
|
60
|
+
"properties": {"surface": "ice"},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "Objects",
|
|
66
|
+
"type": "object",
|
|
67
|
+
"visible": True,
|
|
68
|
+
"locked": False,
|
|
69
|
+
"opacity": 1.0,
|
|
70
|
+
"z_index": 1,
|
|
71
|
+
"tiles": {},
|
|
72
|
+
"objects": {
|
|
73
|
+
"5": {
|
|
74
|
+
"area": {"x": 64, "y": 96, "w": 16, "h": 16},
|
|
75
|
+
"ttype": 0,
|
|
76
|
+
"tileset_type": "object",
|
|
77
|
+
"variant": 1,
|
|
78
|
+
"properties": {},
|
|
79
|
+
},
|
|
80
|
+
"7": {
|
|
81
|
+
"area": {"x": 8, "y": 24, "w": 16, "h": 16},
|
|
82
|
+
"ttype": 0,
|
|
83
|
+
"tileset_type": "object",
|
|
84
|
+
"variant": 0,
|
|
85
|
+
"properties": {"pickup": "coin"},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
COLLISION_PAYLOAD = {
|
|
94
|
+
"tileset_name": "ground",
|
|
95
|
+
"tile_size": [16, 16],
|
|
96
|
+
"tiles": {
|
|
97
|
+
"0": {
|
|
98
|
+
"shapes": [
|
|
99
|
+
{
|
|
100
|
+
"vertices": [[0, 0], [16, 0], [16, 16], [0, 16]],
|
|
101
|
+
"one_way": False,
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"properties": {"surface": "gear"},
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _write_fixture(tmp_path: Path) -> None:
|
|
111
|
+
data = tmp_path / "data"
|
|
112
|
+
(data / "collision").mkdir(parents=True)
|
|
113
|
+
(tmp_path / "assets").mkdir()
|
|
114
|
+
|
|
115
|
+
sheet = pygame.Surface((32, 16), pygame.SRCALPHA)
|
|
116
|
+
pygame.draw.rect(sheet, (255, 64, 64), (0, 0, 16, 16))
|
|
117
|
+
pygame.draw.rect(sheet, (64, 160, 255), (16, 0, 16, 16))
|
|
118
|
+
pygame.image.save(sheet, str(tmp_path / "assets" / "tileset.png"))
|
|
119
|
+
|
|
120
|
+
with open(data / "map.json", "w") as f:
|
|
121
|
+
json.dump(MAP_PAYLOAD, f, indent=2)
|
|
122
|
+
with open(data / "collision" / "ground.collision.json", "w") as f:
|
|
123
|
+
json.dump(COLLISION_PAYLOAD, f, indent=2)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def test_fixture_loads_map_with_expected_ids(tmp_path, monkeypatch):
|
|
127
|
+
monkeypatch.chdir(tmp_path)
|
|
128
|
+
_write_fixture(tmp_path)
|
|
129
|
+
data = load_map("data/map.json")
|
|
130
|
+
layer = data.get_layer("Objects")
|
|
131
|
+
assert layer is not None
|
|
132
|
+
assert set(layer.objects) == {5, 7}
|
|
133
|
+
assert layer.objects[7].properties == {"pickup": "coin"}
|
|
134
|
+
assert data.get_tile_at("Terrain", 1, 0).properties == {"surface": "ice"}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@pytest.mark.parametrize(
|
|
138
|
+
"snippet", SNIPPETS, ids=[s["id"] for s in SNIPPETS]
|
|
139
|
+
)
|
|
140
|
+
def test_cookbook_snippet_runs(snippet, tmp_path, monkeypatch):
|
|
141
|
+
monkeypatch.chdir(tmp_path)
|
|
142
|
+
_write_fixture(tmp_path)
|
|
143
|
+
namespace: dict = {"__name__": f"cookbook.{snippet['id']}"}
|
|
144
|
+
exec(compile(snippet["code"], f"<cookbook:{snippet['id']}>", "exec"), namespace)
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def test_snippets_reference_stable_fixture_positions():
|
|
148
|
+
# Keeps the snippet asserts and the fixture payload from drifting apart.
|
|
149
|
+
for snippet in SNIPPETS:
|
|
150
|
+
if "layer.objects[7]" in snippet["code"]:
|
|
151
|
+
obj_area = MAP_PAYLOAD["data"]["layers"][1]["objects"]["7"]["area"]
|
|
152
|
+
assert "(8, 24, 16, 16)" in snippet["code"]
|
|
153
|
+
assert obj_area == {"x": 8, "y": 24, "w": 16, "h": 16}
|
|
@@ -5,6 +5,8 @@ Covers the conservative contract:
|
|
|
5
5
|
(edge -> normal -> angle), not tile identity / bounding box.
|
|
6
6
|
- CollisionResult.ground_angle / ground_normal are post-move state.
|
|
7
7
|
- World-X velocity preserved: no cos() scaling.
|
|
8
|
+
- Tile identity of the winning support: cell coords + gid (tile-based
|
|
9
|
+
supports only; bodies / airborne read None).
|
|
8
10
|
"""
|
|
9
11
|
|
|
10
12
|
import math
|
|
@@ -20,6 +22,7 @@ from tilemap_parser.parser.collision import (
|
|
|
20
22
|
RectangleShape,
|
|
21
23
|
TileCollisionData,
|
|
22
24
|
TilesetCollision,
|
|
25
|
+
parse_tileset_collision,
|
|
23
26
|
)
|
|
24
27
|
from tilemap_parser.runtime.body import Body
|
|
25
28
|
from tilemap_parser.runtime.movement import CollisionRunner
|
|
@@ -247,3 +250,148 @@ def test_y_query_delegates_to_info_query():
|
|
|
247
250
|
info = r._find_walkable_ground_info(s, ts, {(5, 5): 0}, max_up=10.0, max_down=10.0)
|
|
248
251
|
assert y is not None and info is not None
|
|
249
252
|
assert y == info.y
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
# --- Tile identity underfoot -------------------------------------------
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_flat_reports_winning_cell_and_gid():
|
|
259
|
+
r = CollisionRunner.from_game_type("platformer", (32, 32))
|
|
260
|
+
ts = make_tileset()
|
|
261
|
+
s = MockSprite(x=160, y=160 - 32 - 0.01)
|
|
262
|
+
s.on_ground = True
|
|
263
|
+
res = r.move_platformer_with_slide(s, ts, {(5, 5): 0}, dt=0.016, input_x=0)
|
|
264
|
+
assert res.on_ground is True
|
|
265
|
+
assert res.ground_tile == (5, 5)
|
|
266
|
+
assert res.ground_tile_id == 0
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
def test_winning_cell_is_lowest_ground_across_foot_span():
|
|
270
|
+
# Feet span cols 5 (tilted, top edge starts at y=+3) and 6 (flat low-y):
|
|
271
|
+
# the flat tile in col 6 supports lowest -> identity is (6, 5).
|
|
272
|
+
r = CollisionRunner.from_game_type("platformer", (32, 32))
|
|
273
|
+
ts = make_tileset()
|
|
274
|
+
s = MockSprite(x=170, y=160 - 32 - 0.01)
|
|
275
|
+
s.on_ground = True
|
|
276
|
+
res = r.move_platformer_with_slide(s, ts, {(5, 5): 4, (6, 5): 0}, dt=0.016, input_x=0)
|
|
277
|
+
assert res.on_ground is True
|
|
278
|
+
assert res.ground_tile == (6, 5)
|
|
279
|
+
assert res.ground_tile_id == 0
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def test_airborne_gives_identity_none():
|
|
283
|
+
r = CollisionRunner.from_game_type("platformer", (32, 32))
|
|
284
|
+
ts = make_tileset()
|
|
285
|
+
s = MockSprite(x=100, y=100)
|
|
286
|
+
res = r.move_platformer_with_slide(s, ts, {}, dt=0.016, input_x=0)
|
|
287
|
+
assert res.on_ground is False
|
|
288
|
+
assert res.ground_tile is None
|
|
289
|
+
assert res.ground_tile_id is None
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
def test_jump_clears_identity():
|
|
293
|
+
r = CollisionRunner.from_game_type("platformer", (32, 32))
|
|
294
|
+
ts = make_tileset()
|
|
295
|
+
s = MockSprite(x=160, y=160 - 32 - 0.01)
|
|
296
|
+
s.on_ground = True
|
|
297
|
+
res = r.move_platformer_with_slide(s, ts, {(5, 5): 0}, dt=0.016, input_x=0, jump_pressed=True)
|
|
298
|
+
assert res.ground_tile is None
|
|
299
|
+
assert res.ground_tile_id is None
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
def test_world_path_reports_gid_as_stored():
|
|
303
|
+
# World path: cell entries are (gid, flags) stacks; gid must come
|
|
304
|
+
# through unmodified, including flipped entries.
|
|
305
|
+
world = PhysicsWorld(tile_size=(32, 32))
|
|
306
|
+
world.tileset_collision = make_tileset()
|
|
307
|
+
world.tile_map = {(5, 5): ((0, 0),)}
|
|
308
|
+
runner = CollisionRunner.from_world(world, game_type="platformer")
|
|
309
|
+
s = MockSprite(x=160, y=160 - 32 - 0.01)
|
|
310
|
+
s.on_ground = True
|
|
311
|
+
res = runner.move_platformer_with_slide(s, None, None, dt=0.016, input_x=0)
|
|
312
|
+
assert res.on_ground is True
|
|
313
|
+
assert res.ground_tile == (5, 5)
|
|
314
|
+
assert res.ground_tile_id == 0
|
|
315
|
+
assert res.ground_angle == 0.0
|
|
316
|
+
|
|
317
|
+
|
|
318
|
+
def test_world_path_body_support_has_no_identity():
|
|
319
|
+
world = PhysicsWorld(tile_map={}, tileset_collision=None, tile_size=(32, 32))
|
|
320
|
+
world.add_body(
|
|
321
|
+
Body(collision_shape=RectangleShape(width=200, height=16), x=0, y=80)
|
|
322
|
+
)
|
|
323
|
+
runner = CollisionRunner.from_world(world, game_type="platformer")
|
|
324
|
+
s = MockSprite(x=50, y=80 - 32 - 0.01)
|
|
325
|
+
s.on_ground = True
|
|
326
|
+
res = runner.move_platformer_with_slide(s, None, None, dt=0.016, input_x=0)
|
|
327
|
+
assert res.on_ground is True
|
|
328
|
+
assert res.ground_angle == 0.0
|
|
329
|
+
assert res.ground_tile is None
|
|
330
|
+
assert res.ground_tile_id is None
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def test_result_identity_does_not_leak_from_reused_result():
|
|
334
|
+
# Reused _result object: a slide-mode call after a platformer call
|
|
335
|
+
# must not carry stale ground tile identity.
|
|
336
|
+
from tilemap_parser.runtime.movement.types import MovementMode
|
|
337
|
+
|
|
338
|
+
r = CollisionRunner.from_game_type("platformer", (32, 32))
|
|
339
|
+
ts = make_tileset()
|
|
340
|
+
s = MockSprite(x=160, y=160 - 32 - 0.01)
|
|
341
|
+
s.on_ground = True
|
|
342
|
+
res = r.move_platformer_with_slide(s, ts, {(5, 5): 0}, dt=0.016, input_x=0)
|
|
343
|
+
assert res.ground_tile_id == 0
|
|
344
|
+
r.mode = MovementMode.SLIDE
|
|
345
|
+
res2 = r.move(s, ts, {(5, 5): 0}, delta_x=8.0)
|
|
346
|
+
assert res2.ground_tile is None
|
|
347
|
+
assert res2.ground_tile_id is None
|
|
348
|
+
|
|
349
|
+
|
|
350
|
+
# --- Properties passthrough ---------------------------------------------
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
def test_tile_properties_survive_parse():
|
|
354
|
+
import json
|
|
355
|
+
|
|
356
|
+
payload = {
|
|
357
|
+
"tileset_name": "props_ts",
|
|
358
|
+
"tile_size": [32, 32],
|
|
359
|
+
"tiles": {
|
|
360
|
+
"7": {
|
|
361
|
+
"shapes": [
|
|
362
|
+
{"vertices": FULL, "one_way": False}
|
|
363
|
+
],
|
|
364
|
+
"properties": {
|
|
365
|
+
"collision_layer": 2,
|
|
366
|
+
"collision_mask": 3,
|
|
367
|
+
"surface": "gear",
|
|
368
|
+
"surface_speed": 120,
|
|
369
|
+
},
|
|
370
|
+
}
|
|
371
|
+
},
|
|
372
|
+
}
|
|
373
|
+
ts = parse_tileset_collision(json.loads(json.dumps(payload)))
|
|
374
|
+
data = ts.tiles[7]
|
|
375
|
+
assert data.has_collision()
|
|
376
|
+
assert data.properties["surface"] == "gear"
|
|
377
|
+
assert data.properties["surface_speed"] == 120
|
|
378
|
+
assert data.collision_layer == 2
|
|
379
|
+
assert data.collision_mask == 3
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
def test_merge_preserves_properties():
|
|
383
|
+
ts = make_tileset()
|
|
384
|
+
ts.tiles[2].properties = {"surface": "ice"}
|
|
385
|
+
merged = TilesetCollision.merge([ts], [100])
|
|
386
|
+
assert merged.tiles[102].properties == {"surface": "ice"}
|
|
387
|
+
assert merged.tiles[100 + 0].properties == {}
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def test_flipped_copy_preserves_properties():
|
|
391
|
+
from tilemap_parser.runtime.world import flipped_data
|
|
392
|
+
|
|
393
|
+
ts = make_tileset()
|
|
394
|
+
ts.tiles[0].properties = {"surface": "gear"}
|
|
395
|
+
out = flipped_data(ts.tiles[0], 0x80000000, (32, 32))
|
|
396
|
+
assert out is not ts.tiles[0] # flipped copy
|
|
397
|
+
assert out.properties == {"surface": "gear"}
|
|
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
|
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/animation_player.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/collision/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/collision/manager.py
RENAMED
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/collision/shapes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/movement/__init__.py
RENAMED
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/navigation/__init__.py
RENAMED
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/navigation/nav_grid.py
RENAMED
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/navigation/path_follower.py
RENAMED
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/src/tilemap_parser/runtime/navigation/pathfinder.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{tilemap_parser-6.0.0 → tilemap_parser-6.0.1}/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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|