Skip to main content

Module map

Module map 

Source
Expand description

Runtime map loading for zero-Rust game projects.

A map lives in <maps_dir>/<MapId>/ and consists of:

  • map.tmx.json — a Tiled JSON map. Visual layers render in stack order, split at the player’s elevation by their integer custom property level (default 0): level <= player elevation draws below sprites, above it draws over them. The data layers are never rendered: collision is the level-0 collision grid, collisionN the level-N grid (any non-zero GID marks a solid tile at that level), and stairs marks elevation transitions (GID 1 = ascend on arrival, 2 = descend).
  • tileset.png — a row-major tile atlas sliced by crate::tileset::PngTileset using the TMX tilewidth/tileheight.
  • an entity sidecar — the dotzuki-editor writes objects.json ({npcs, warps, …}); older fixtures used map.json. MapObjects::load tries objects.json first and falls back to map.json; neither being present yields an empty sidecar, not an error.

Structs§

EncounterConfig
Random-encounter configuration in the objects sidecar (same shape as pokered’s wild_data: a per-step rate byte in /256 units — rate: 25 ≈ a 9.8% trigger chance per step — plus grass-like zones).
EncounterTableEntry
A random-encounter table entry: a species/encounter id and its relative weight. The id is resolved at battle start by crate::battle::BattleSetup::start_with — an encounter record first, then a single enemy record (trainer queues and wild singles both work).
EncounterZone
One encounter zone: an inclusive map-tile rectangle plus the weighted table drawn from when a step lands inside it.
MapObjects
The per-map entity sidecar: NPCs, warps, signs and random encounters.
NpcDef
A placed NPC in the per-map objects sidecar.
RuntimeMap
A loaded runtime map: visual layers, per-level collision grids, the stairs grid, tileset pixels and the entity sidecar.
SignDef
A sign tile in the objects sidecar.
WarpDef
A warp tile in the objects sidecar.

Constants§

LEGACY_SIDECAR
Legacy sidecar filename, read as a fallback when objects.json is absent.
OBJECTS_SIDECAR
Filename of the entity sidecar the dotzuki-editor writes today.

Functions§

map_dir
Convenience: the directory of one map under a project’s maps dir.