pub struct OverworldActor { /* private fields */ }Expand description
A walking overworld actor (player or NPC): tile target + interpolated pixel
position + facing + walk animation. Tile size is configurable (tile).
Implementations§
Source§impl OverworldActor
impl OverworldActor
Sourcepub fn new(tile_x: i32, tile_y: i32, tile: i32) -> Self
pub fn new(tile_x: i32, tile_y: i32, tile: i32) -> Self
Spawn at tile (tile_x, tile_y) facing down, with tile-px tiles.
pub fn facing(&self) -> Direction
pub fn set_facing(&mut self, dir: Direction)
pub fn is_moving(&self) -> bool
Sourcepub fn set_running(&mut self, running: bool)
pub fn set_running(&mut self, running: bool)
Set whether the actor is running this frame — the consumer calls this each
frame (e.g. from a held run button) before update. Running
uses a faster step speed and animation; the renderer reads
locomotion + step_phase to pick frames.
pub fn is_running(&self) -> bool
Sourcepub fn px(&self) -> f32
pub fn px(&self) -> f32
Interpolated foot-tile top-left, in world pixels (for camera + drawing).
pub fn py(&self) -> f32
Sourcepub fn set_elevation(&mut self, level: u8)
pub fn set_elevation(&mut self, level: u8)
Set the elevation level (stair transitions, spawns, save restore). The caller clamps to the map’s level count.
Sourcepub fn place(&mut self, x: i32, y: i32, dir: Direction)
pub fn place(&mut self, x: i32, y: i32, dir: Direction)
Snap to tile (x, y), facing dir, stationary (warps, spawns, debug teleport).
Sourcepub fn update(
&mut self,
held: Option<Direction>,
map: &impl OverworldCollision,
) -> Option<(i32, i32)>
pub fn update( &mut self, held: Option<Direction>, map: &impl OverworldCollision, ) -> Option<(i32, i32)>
Advance one frame. When idle and held is set, the actor turns to face it and
— if the next tile isn’t OverworldCollision::is_blocked_at at the
actor’s elevation — begins a step.
The in-progress step’s pixel interpolation is advanced. Returns Some((x, y))
on the frame a step completes (the tile just arrived on) so the caller can
check warps; None otherwise.
Sourcepub fn facing_row(&self) -> u32
pub fn facing_row(&self) -> u32
Sprite-sheet row for the current facing (the convention WalkSprite and the
character-sprite-gen skill author: down=0, up=1, left=2, right=3).
Sourcepub fn walk_frame(&self) -> u32
pub fn walk_frame(&self) -> u32
Generic 3-frame walk index: 0 = neutral/idle, 1/2 = the two step frames
(alternating while walking). The consumer maps this to its sheet’s columns
(a clean sheet uses it directly; a sheet whose neutral pose is elsewhere remaps).
Sourcepub fn locomotion(&self) -> Locomotion
pub fn locomotion(&self) -> Locomotion
Locomotion state for picking sprite columns: Idle when stationary, else
Run if the run flag is set (set_running) else Walk.
Sourcepub fn step_phase(&self) -> u32
pub fn step_phase(&self) -> u32
Which of the two step frames to show (0 or 1), alternating faster while
running. Pair with frame_col to resolve the actual sheet column.
Trait Implementations§
Source§impl Clone for OverworldActor
impl Clone for OverworldActor
Source§fn clone(&self) -> OverworldActor
fn clone(&self) -> OverworldActor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more