Skip to main content

Module actor

Module actor 

Source
Expand description

Render- and map-model-agnostic overworld walking actor.

The GB-shaped overworld (super::player_movement over MapTrait+TilesetTrait with u8 coords and 4×4 blocks) doesn’t fit full-color games whose maps are source-direct image grids with i32 coords. This is the generic actor every game can drive: it owns tile position, smooth pixel interpolation, facing, and the walk-cycle animation state, asking the map only OverworldCollision::is_blocked.

It returns indices, never pixels — the consumer’s renderer is free (wuxia/minimon blit a full-color crate-external WalkSprite; pokered keeps its GB-OAM painter). NPC occupancy and warps stay caller-side: fold NPCs into is_blocked, and check warps against the tile OverworldActor::update reports a step completed on.

Structs§

OverworldActor
A walking overworld actor (player or NPC): tile target + interpolated pixel position + facing + walk animation. Tile size is configurable (tile).

Enums§

Locomotion
Locomotion state the renderer maps to sprite columns: standing, walking, or running. Run only looks distinct when the sheet has dedicated run frames (the canonical overworld layout puts them at cols 3/4 — see frame_col); otherwise the consumer reuses the walk frames at the faster running cadence.

Traits§

OverworldCollision
The minimum a map must answer for the actor to move: is walking onto (x, y) blocked? Out-of-bounds should return true (enclosed world). Callers fold in dynamic collision (NPC tiles, locked doors) by composing it into this impl.

Functions§

frame_col
Resolve the sprite-sheet column for a locomotion state + step phase, given the sheet’s column count. Canonical overworld layout: col 0 = stand, cols 1/2 = walk, cols 3/4 = run. Sheets without run frames (cols < 5) reuse the walk columns while running (the faster cadence still reads as a run). phase is 0/1 from OverworldActor::step_phase.