feat: v0.1.2 sprite-mode in draw_map + tile_rotations + load_textures
Sprite-mode in draw_map: - tilemap-tiles with texture atlas-id render via engine.render.draw_sprite_transform with rotation pivot at tile center - tiles without texture continue to render via draw_rect with color (Phase 1 mode preserved) Tile rotation: - maps support an optional tile_rotations parallel array in the map JSON with per-cell 90-degree rotation values (0/90/180/270) - absent or nil entries default to 0 (no rotation) - enables 9-segment tile reuse via rotation rather than per-orientation sprites New API: - maps.load_textures(asset_aliases) resolves the current tilemap's tile atlas-ids to texture-handles via the asset-lib indirection (asset_aliases[tilemap.asset_pack] -> lib-id -> atlas.json lookup per tile) Schema additions: - tilemap.asset_pack (alias-key, optional) - tile.texture (atlas-id, optional) - map.tile_rotations (parallel array, optional) All existing Phase 1 color-only tilemaps render unchanged.
This commit is contained in:
33
README.md
33
README.md
@@ -2,7 +2,7 @@
|
||||
|
||||
Single tile-grid map implementation. Loads JSON map + tilemap files, registers maps by id, and provides tile-fetch + walkability + size queries with current-map sugar.
|
||||
|
||||
**Version:** 0.1.1
|
||||
**Version:** 0.1.2
|
||||
**Lib-ID:** lib-core.maps
|
||||
**Requires:** (none)
|
||||
**Tags:** maps, tile-grid, walkability, tilemap
|
||||
@@ -93,6 +93,22 @@ if tile then engine.print(tile.id) end
|
||||
|
||||
**Description:** Returns an array of all registered map-ids.
|
||||
|
||||
### `maps.load_textures(asset_aliases)`
|
||||
**Syntax:** `maps.load_textures(asset_aliases: {[string]: string}) -> void`
|
||||
|
||||
**Example:**
|
||||
```lua
|
||||
maps.set_current(map_id)
|
||||
maps.load_textures({ terrain = "lib-core.terrain-assets" })
|
||||
```
|
||||
|
||||
**Description:** Resolves the current tilemap's tile `texture` atlas-ids to texture-handles via the asset-lib indirection. `asset_aliases` maps the tilemap's `asset_pack` alias-key to a lib-id; the lib's `assets/atlas.json` is read to locate each texture file. Populates `tile.texture_handle` on each tile in-place. No-op if the tilemap has no `asset_pack`. Call once at module init after `set_current`; do not call repeatedly (texture handles are not auto-cached).
|
||||
|
||||
### `maps.draw_map()`
|
||||
**Syntax:** `maps.draw_map() -> void`
|
||||
|
||||
**Description:** Draws the current map grid. Tiles with a resolved `texture_handle` render via `engine.render.draw_sprite_transform` with rotation about the tile center (using the map's optional `tile_rotations` parallel array). Tiles without a texture handle fall back to `engine.render.draw_rect` with `tile.color` (Phase 1 mode). No-op if no current map.
|
||||
|
||||
### `maps.state(map_id)`
|
||||
**Syntax:** `maps.state(map_id: string) -> string`
|
||||
|
||||
@@ -130,6 +146,21 @@ end
|
||||
|
||||
## CHANGELOG
|
||||
|
||||
### v0.1.2
|
||||
- Sprite-mode in draw_map: tilemap-tiles with `texture` atlas-id render
|
||||
via engine.render.draw_sprite_transform; tiles without `texture` fall
|
||||
back to color-rect render (Phase 1 mode).
|
||||
- Map-data tile_rotations parallel array support: per-cell 90-degree
|
||||
rotation in {0, 90, 180, 270}, applied at draw via rotation about
|
||||
the tile center. Optional; absent means all-zero.
|
||||
- New API: maps.load_textures(asset_aliases) resolves the current
|
||||
tilemap's tile atlas-ids to texture-handles via the asset-lib
|
||||
indirection. Mirrors the puppet.load_textures pattern.
|
||||
- Tilemap schema additions: tilemap.asset_pack (alias-key),
|
||||
tile.texture (atlas-id).
|
||||
- Backward-compat: existing Phase 1 color-only tilemaps render
|
||||
unchanged.
|
||||
|
||||
### v0.1.1
|
||||
- Tilemap-id resolution handles module-ids with dots (prefix-match instead of first-dot split).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user