Skip to content

feat(tiled): load maps made in the Tiled editor (TILE-1) - #158

Merged
NastMz merged 9 commits into
mainfrom
feat/tile-1
Nov 13, 2026
Merged

NastMz merged 9 commits into
mainfrom
feat/tile-1

Conversation

@NastMz

@NastMz NastMz commented Nov 13, 2026

Copy link
Copy Markdown
Owner

Summary

  • TILE-1: a developer outside the repository can now build levels in the Tiled editor and load them with the published SDK. The evaluation (docs/evaluations/tile-1.md) recommended option 1, which the owner approved and ADR 0052 records: an optional MicroEngine.Tiled package over DotTiled whose public API uses engine types only.
  • Fixes TileRenderer, which skipped the tiles a zoomed-out or rotated camera shows, and lets it draw mirrored and turned cells.

Changes

  • Engine: TileRenderer culls with Camera2D.VisibleBounds. New TileOrientation type, and a Draw overload with per-cell orientation, offset, tint and margin.

  • MicroEngine.Tiled, the ninth SDK package (optional, managed only):

    • Loads .tmx and .tmj maps with their tilesets and templates through the game's assets (Assets.TiledMap).
    • Tile layers keep each cell's flips; tilesets become sprites (TiledSprites), animations and image collections included.
    • Objects and typed properties are data; templates are merged; CollisionGrid reads collision from a tile property the game names.
    • Tile objects, object layers and parallax draw as Tiled shows them.
  • DotTiled 1.0.0 defects worked around in the package, each pinned by a test:

    • It resolved a template's tileset against the map's folder.
    • Its TMJ reader replaced a template's properties instead of merging them.
    • Its tile source rectangles came back empty.
  • Release path:

    • sdk/version.mjs adds the package; it is not required of the versions already published.
    • The package checks, the samples check, THIRD-PARTY-NOTICES.md and the architecture table include it.
  • Sample: samples/TiledLevel plays Tiled's own Sticker Knight map (public domain, CREDITS.md), which the Tiled editor saved.

  • Benchmark: benchmarks/MapBench, on a 1000 × 1000 map with three compressed layers:

    Measurement Median
    Load 80 ms
    One frame at zoom 1 82 µs
    One frame at zoom 0.5 244 µs
  • Docs:

    • A "Maps from Tiled" section in docs/manual/world.md, quoting the sample.
    • The API reference for the package, the SDK package table, and the release notes under ## Next release.
    • ADR 0052 and the record in odd/tasks/tile-1.md.
  • Unrelated chore: .gitignore ignores the local trailer*/ and channel-art/ folders.

Testing

  • dotnet test MicroEngine.slnx -c Release: every project passes. The new tests are MicroEngine.Tiled.Tests (25), TileRendererTests (4) and TiledLevelTests (2). The architecture table needed the new package, which the first run caught; it now passes.
  • node --test sdk/tests/version.test.mjs: 29/29.
  • node site/scripts/snippets.mjs: passes.
  • astro build: passes. check-dist reported only the demo files, which were not fetched locally.
  • Sample tour captured headless and inspected: the level draws with parallax, coins are collected, and the hero lands on the castle platform.
  • Not run: a NativeAOT publish and a browser build of the sample, and sdk/tests/docs.mjs against the packed feed (CI runs it).

Closes #121

TileRenderer skipped tiles with Camera2D.View, which ignores zoom and
rotation, so a zoomed-out camera left the outer tiles undrawn. It now
culls with VisibleBounds plus the shake margin. A new overload takes a
per-cell TileOrientation (Tiled's flip bits) and an extra margin.
…ects

MicroEngine.Tiled reads .tmx and .tmj maps, with their external
tilesets and templates, through the game's assets: tile layers with
each cell's flips, tilesets as sprites (tall tiles and animations
included), objects as records with typed properties, and a collision
grid from a tile property the game names. DotTiled parses the files and
never appears in the public API. TileRenderer's new overload takes the
layer's offset and tint.
The version tool lists it (never required of the versions already
published), the package check knows its files and dependencies, the
samples swap its package reference for the project, and the notices
list DotTiled.
…ts own folder

DotTiled 1.0.0's loader resolves a template's tileset against the map's
folder, so a template in another folder failed to load; the package now
resolves every reference from the folder of the file that names it.
Tile objects draw as Tiled shows them (stretched, mirrored, turned about
their bottom-left corner), object layers draw their tile objects,
TiledMap.ParallaxShift gives Tiled's parallax, TiledObject.TurnedBounds
the box around a turned object, and image collections with gaps in their
ids list only the tiles they have.
TiledLevel loads Tiled's own Sticker Knight example map (public domain)
through the MicroEngine.Tiled package: the objects whose bodyType the
designer set are solid, the coin template's instances are collected and
every layer draws with its parallax. Its tour script is played by the
documented samples check and its tests by Samples.Tests.
…ture table

MapBench writes a 1000 x 1000 map of three compressed layers and times
its load and one frame of drawing at zoom 1 and 0.5.
The world manual gains a Maps from Tiled section quoting the TiledLevel
sample, the API reference covers MicroEngine.Tiled, and the release
notes list the package and the TileRenderer fix under the next release.
@github-actions

Copy link
Copy Markdown

Preview of 9d73602 (candidates demos): https://micro-engine-557s1r2ck-nastmzs-projects.vercel.app

@NastMz
NastMz merged commit 16af5af into main Nov 13, 2026
43 checks passed
@NastMz
NastMz deleted the feat/tile-1 branch November 13, 2026 23:05

This branch was successfully deployed

1 active deployment
preview — 9d73602a Deployed Nov 13, 2026 by NastMz via Site / Deploy preview #419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TILE-1 — Investigate external tilemap tooling and scalable 2D maps

1 participant