tilemap-parser 3.1.17__tar.gz → 3.1.18__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.
Files changed (36) hide show
  1. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/PKG-INFO +1 -1
  2. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/pyproject.toml +1 -1
  3. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/__init__.py +1 -0
  4. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/__init__.py +2 -0
  5. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/tile_collision.py +52 -0
  6. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser.egg-info/PKG-INFO +1 -1
  7. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/LICENSE +0 -0
  8. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/README.md +0 -0
  9. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/setup.cfg +0 -0
  10. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/parser/__init__.py +0 -0
  11. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/parser/animation.py +0 -0
  12. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/parser/collision.py +0 -0
  13. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/parser/collision_loader.py +0 -0
  14. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/parser/map_parse.py +0 -0
  15. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/parser/node_parse.py +0 -0
  16. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/parser/particle.py +0 -0
  17. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/animation_player.py +0 -0
  18. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/area_node.py +0 -0
  19. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/collision_cache.py +0 -0
  20. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/map_loader.py +0 -0
  21. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/object_collision.py +0 -0
  22. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/particles.py +0 -0
  23. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/runtime/renderer.py +0 -0
  24. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/utils/__init__.py +0 -0
  25. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser/utils/geometry.py +0 -0
  26. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser.egg-info/SOURCES.txt +0 -0
  27. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser.egg-info/dependency_links.txt +0 -0
  28. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser.egg-info/requires.txt +0 -0
  29. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/src/tilemap_parser.egg-info/top_level.txt +0 -0
  30. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/tests/test_collision.py +0 -0
  31. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/tests/test_geometry.py +0 -0
  32. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/tests/test_map_loader.py +0 -0
  33. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/tests/test_object_collision.py +0 -0
  34. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/tests/test_object_surfaces.py +0 -0
  35. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/tests/test_render_scale.py +0 -0
  36. {tilemap_parser-3.1.17 → tilemap_parser-3.1.18}/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.17
3
+ Version: 3.1.18
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.17"
7
+ version = "3.1.18"
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"
@@ -82,4 +82,5 @@ __all__ = [
82
82
  "polygon_vs_rect",
83
83
  "rect_vs_circle",
84
84
  "rect_vs_rect",
85
+ "rect_vs_tilemap",
85
86
  ]
@@ -14,6 +14,7 @@ from .tile_collision import (
14
14
  CollisionRunner,
15
15
  ICollidableSprite,
16
16
  MovementMode,
17
+ rect_vs_tilemap,
17
18
  )
18
19
  from .map_loader import TilemapData, load_map
19
20
  from .object_collision import (
@@ -63,6 +64,7 @@ __all__ = [
63
64
  "ParticleEmitterNode",
64
65
  "ParticleRenderer",
65
66
  "ParticleSystem",
67
+ "rect_vs_tilemap",
66
68
  "SpriteBatchRenderer",
67
69
  "clear_texture_caches",
68
70
  ]
@@ -1936,3 +1936,55 @@ class CollisionRunner:
1936
1936
  raise ValueError(warning_msg)
1937
1937
  else:
1938
1938
  warnings.warn(warning_msg, UserWarning, stacklevel=2)
1939
+
1940
+
1941
+ def rect_vs_tilemap(
1942
+ left: float,
1943
+ top: float,
1944
+ right: float,
1945
+ bottom: float,
1946
+ tile_map: Dict[Tuple[int, int], int],
1947
+ tileset_collision: TilesetCollision,
1948
+ tile_size: Tuple[int, int],
1949
+ render_scale: float = 1.0,
1950
+ ) -> bool:
1951
+ """Check if an AABB collides with any collision tile in a tile map.
1952
+
1953
+ Iterates overlapping tiles, transforms each tile's collision polygons to
1954
+ world space, and tests for intersection with the given rectangle.
1955
+
1956
+ Args:
1957
+ left, top, right, bottom: World-space AABB of the query rect.
1958
+ tile_map: Dict mapping (col, row) -> tile_variant_id.
1959
+ tileset_collision: TilesetCollision with per-tile polygon shapes.
1960
+ tile_size: Raw tile size as (width, height) from map data.
1961
+ render_scale: Multiplier from tile-local to world pixels.
1962
+
1963
+ Returns:
1964
+ True if the rect overlaps any tile collision polygon.
1965
+ """
1966
+ tw = tile_size[0] * render_scale
1967
+ th = tile_size[1] * render_scale
1968
+ tx0 = math.floor(left / tw)
1969
+ tx1 = math.floor((right - 1) / tw)
1970
+ ty0 = math.floor(top / th)
1971
+ ty1 = math.floor((bottom - 1) / th)
1972
+ rw = right - left
1973
+ rh = bottom - top
1974
+
1975
+ for ty in range(ty0, ty1 + 1):
1976
+ for tx in range(tx0, tx1 + 1):
1977
+ tile_id = tile_map.get((tx, ty))
1978
+ if tile_id is None:
1979
+ continue
1980
+ tile_data = tileset_collision.tiles.get(tile_id)
1981
+ if tile_data is None:
1982
+ continue
1983
+ ox = tx * tw
1984
+ oy = ty * th
1985
+ for poly in tile_data.shapes:
1986
+ if not poly.is_valid():
1987
+ continue
1988
+ if _rect_polygon_collision_offset(left, top, rw, rh, poly.vertices, ox, oy, render_scale):
1989
+ return True
1990
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tilemap-parser
3
- Version: 3.1.17
3
+ Version: 3.1.18
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