tilemap-parser 3.0.0__tar.gz → 3.1.0__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.0.0 → tilemap_parser-3.1.0}/PKG-INFO +1 -1
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/pyproject.toml +1 -1
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/object_collision.py +25 -1
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser.egg-info/PKG-INFO +1 -1
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/tests/test_object_collision.py +67 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/LICENSE +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/README.md +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/setup.cfg +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/__init__.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/parser/__init__.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/parser/animation.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/parser/collision.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/parser/collision_loader.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/parser/map_parse.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/__init__.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/animation_player.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/collision_cache.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/map_loader.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/renderer.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/tile_collision.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/utils/__init__.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/utils/geometry.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser.egg-info/SOURCES.txt +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser.egg-info/dependency_links.txt +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser.egg-info/requires.txt +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser.egg-info/top_level.txt +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/tests/test_collision.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/tests/test_geometry.py +0 -0
- {tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/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.
|
|
3
|
+
Version: 3.1.0
|
|
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.
|
|
7
|
+
version = "3.1.0"
|
|
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"
|
{tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/object_collision.py
RENAMED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object-to-object collision detection runtime.
|
|
3
3
|
|
|
4
4
|
Provides a protocol-based interface, shape dispatch, layer filtering,
|
|
5
|
-
a multi-object manager, and collision hit helpers for separation/resolve.
|
|
5
|
+
a multi-object manager, and collision hit helpers for separation/resolve/slide.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
from __future__ import annotations
|
|
@@ -72,6 +72,30 @@ class CollisionHit:
|
|
|
72
72
|
self.object_b.x += sep_x
|
|
73
73
|
self.object_b.y += sep_y
|
|
74
74
|
|
|
75
|
+
def slide_velocity(self, vx: float, vy: float) -> tuple[float, float]:
|
|
76
|
+
"""Project velocity along the collision surface (slide response).
|
|
77
|
+
|
|
78
|
+
Removes the component of (vx, vy) that is along *self.normal*,
|
|
79
|
+
leaving only the tangential component. Intended for the moving
|
|
80
|
+
object passed as *object_a* — when that object moves into
|
|
81
|
+
*object_b* the approach component is stripped so the object slides
|
|
82
|
+
along the surface instead of penetrating.
|
|
83
|
+
|
|
84
|
+
If the velocity is already parallel to the surface or points away
|
|
85
|
+
from *object_b* the original velocity is returned unchanged.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
vx: X component of velocity (object_a's velocity)
|
|
89
|
+
vy: Y component of velocity
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
(slide_x, slide_y) — velocity projected onto the surface
|
|
93
|
+
"""
|
|
94
|
+
dot = vx * self.normal[0] + vy * self.normal[1]
|
|
95
|
+
if dot > 0:
|
|
96
|
+
return (vx - self.normal[0] * dot, vy - self.normal[1] * dot)
|
|
97
|
+
return (vx, vy)
|
|
98
|
+
|
|
75
99
|
def involves(self, obj: ICollidableObject) -> bool:
|
|
76
100
|
"""Check if this hit involves the given object."""
|
|
77
101
|
return self.object_a is obj or self.object_b is obj
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tilemap-parser
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.1.0
|
|
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
|
|
@@ -338,6 +338,73 @@ class TestCollisionHitHelpers:
|
|
|
338
338
|
with pytest.raises(ValueError, match="not part"):
|
|
339
339
|
hit.other(c)
|
|
340
340
|
|
|
341
|
+
# ------------------------------------------------------------------
|
|
342
|
+
# slide_velocity
|
|
343
|
+
# ------------------------------------------------------------------
|
|
344
|
+
def test_slide_head_on(self):
|
|
345
|
+
"""Directly into surface → zero tangential motion."""
|
|
346
|
+
hit = CollisionHit(
|
|
347
|
+
object_a=None, object_b=None,
|
|
348
|
+
normal=(1.0, 0.0), depth=5.0,
|
|
349
|
+
)
|
|
350
|
+
sx, sy = hit.slide_velocity(10.0, 0.0)
|
|
351
|
+
assert sx == 0.0
|
|
352
|
+
assert sy == 0.0
|
|
353
|
+
|
|
354
|
+
def test_slide_angled(self):
|
|
355
|
+
"""Diagonal into surface → only perpendicular component removed."""
|
|
356
|
+
hit = CollisionHit(
|
|
357
|
+
object_a=None, object_b=None,
|
|
358
|
+
normal=(1.0, 0.0), depth=5.0,
|
|
359
|
+
)
|
|
360
|
+
sx, sy = hit.slide_velocity(10.0, 5.0)
|
|
361
|
+
assert sx == 0.0 # x component fully removed
|
|
362
|
+
assert sy == 5.0 # y component preserved (tangential)
|
|
363
|
+
|
|
364
|
+
def test_slide_parallel(self):
|
|
365
|
+
"""Velocity along the surface → unchanged."""
|
|
366
|
+
hit = CollisionHit(
|
|
367
|
+
object_a=None, object_b=None,
|
|
368
|
+
normal=(0.0, 1.0), depth=5.0,
|
|
369
|
+
)
|
|
370
|
+
sx, sy = hit.slide_velocity(10.0, 0.0)
|
|
371
|
+
assert sx == 10.0
|
|
372
|
+
assert sy == 0.0
|
|
373
|
+
|
|
374
|
+
def test_slide_away(self):
|
|
375
|
+
"""Velocity pointing away from surface → unchanged."""
|
|
376
|
+
hit = CollisionHit(
|
|
377
|
+
object_a=None, object_b=None,
|
|
378
|
+
normal=(1.0, 0.0), depth=5.0,
|
|
379
|
+
)
|
|
380
|
+
sx, sy = hit.slide_velocity(-10.0, 0.0)
|
|
381
|
+
assert sx == -10.0
|
|
382
|
+
assert sy == 0.0
|
|
383
|
+
|
|
384
|
+
def test_slide_zero(self):
|
|
385
|
+
"""Zero velocity → zero."""
|
|
386
|
+
hit = CollisionHit(
|
|
387
|
+
object_a=None, object_b=None,
|
|
388
|
+
normal=(1.0, 0.0), depth=5.0,
|
|
389
|
+
)
|
|
390
|
+
sx, sy = hit.slide_velocity(0.0, 0.0)
|
|
391
|
+
assert sx == 0.0
|
|
392
|
+
assert sy == 0.0
|
|
393
|
+
|
|
394
|
+
def test_slide_diagonal_normal(self):
|
|
395
|
+
"""Normal at 45°, velocity into surface → slide along surface."""
|
|
396
|
+
import math
|
|
397
|
+
n = (1.0 / math.sqrt(2), 1.0 / math.sqrt(2))
|
|
398
|
+
hit = CollisionHit(
|
|
399
|
+
object_a=None, object_b=None,
|
|
400
|
+
normal=n, depth=5.0,
|
|
401
|
+
)
|
|
402
|
+
sx, sy = hit.slide_velocity(1.0, 0.0)
|
|
403
|
+
# Dot = 1/sqrt(2) ≈ 0.707
|
|
404
|
+
# slide = (1, 0) - (0.707, 0.707) * 0.707 = (1 - 0.5, -0.5)
|
|
405
|
+
assert sx == pytest.approx(0.5)
|
|
406
|
+
assert sy == pytest.approx(-0.5)
|
|
407
|
+
|
|
341
408
|
|
|
342
409
|
# ---------------------------------------------------------------------------
|
|
343
410
|
# Capsule collision
|
|
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.0.0 → tilemap_parser-3.1.0}/src/tilemap_parser/runtime/animation_player.py
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
|
{tilemap_parser-3.0.0 → tilemap_parser-3.1.0}/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
|