Expand description
The deterministic simulation: a level of solid tiles and the hero moving through it.
No toolkit types. World::step advances one fixed step of DT; the same
Intents give the same results, so a cloned world plays out identically (the tests
rely on that, and so will rewinds and replays).
Movement follows the Celeste school: integer positions (units) with a fractional
remainder, moved one unit at a time against the tile grid, so collisions are exact and
nothing tunnels. All feel numbers live in Tuning.
On its own: an Intent in each fixed step, Events out.
use game_toolkit_platformer::sim::{Event, Intent, JumpKind, Level, Preset, World};
let mut level = Level::demo();
let mut world = World::on(&level, Preset::Precise.tuning());
world.step(&mut level, &Intent::default());
world.step(&mut level, &Intent { jump_pressed: true, jump_held: true, ..Intent::default() });
assert!(world.events.iter().any(|e| matches!(e, Event::Jumped { kind: JumpKind::Ground, .. })));Re-exports§
pub use ability::Ability;pub use ability::Step;pub use contacts::Contacts;pub use crystal::Crystal;pub use custom_id::CustomId;pub use custom_tile::CustomTile;pub use event::Event;pub use event::JumpKind;pub use grid::Grid;pub use grid::GridTerrain;pub use hold::Hold;pub use intent::Intent;pub use level::Level;pub use level::TILE;pub use level::Tile;pub use moves::Moves;pub use player::Mode;pub use player::Player;pub use rect::Rect;pub use spot::Spot;pub use surface::Surface;pub use terrain::Terrain;pub use tuning::Preset;pub use tuning::Tuning;
Modules§
- ability
Ability: a move of your game’s own (an attack lunge, a ledge grab, a grapple, a pogo), hooked intoWorld::stepwithout forking the movement.- contacts
Contacts: what the body ran into in its last step, for anAbility::afterthat reacts to collisions (a wall-hit stun, a ceiling bonk that breaks a block, a ground pound).- crystal
Crystal: a dash refill floating in the air; used up on touch, back after a while.- custom_
id CustomId: the name of a move or event of your own, forMode::CustomandEvent::Custom.- custom_
tile CustomTile: what aTile::Customis to the movement, set per id withLevel::define.- event
Event: what happened in a step, for animation, sound and effects.- grid
Grid: a tilemap of your own, one answer per tile, turned into theTerrainrules the movement relies on (solid ground, one-way platforms held only from exactly above, the surface under the feet or beside the body) byGridTerrain.Levelanswers by the same rules.- hold
Hold: how aCustomTileholds the character.- intent
Intent: what the player wants this step, independent of keys or pads.- level
Level: a ready-madeTerrain: a grid of tiles (solid, one-way platforms), dash refills and a spawn point. Parse it from ASCII rows, build it from your own tilemap withLevel::from_fn, or implementTerrainfor your own world instead.- moves
Moves: which built-in moves may run in one step. AnAbilityclears what its own move rules out inAbility::before: no dash while attacking, no wall grab while carrying, slow walking while pushing.- player
Player: the hero’s body: position, speed, timers, and the movement rules.- rect
Rect: an integer axis-aligned box, in units or in a terrain’s pixels.- spot
Spot: where to put the character, by its hitbox’s top-left or by its feet.- surface
Surface: what kind of ground or wall the character touches: ice, a conveyor belt, a wall too smooth to climb, a bouncy pad. ATerrainanswers it inTerrain::surface; by default everything isSurface::DEFAULTand theTuningalone sets the feel.- terrain
Terrain: what the movement asks about the world around the character. Your game implements it for its own level (a tilemap, a collision grid, anything): writeTerrain::solidand say what it builds on withterrain_layer!(terrain_layer!()for nothing,terrain_layer!(level)for a field it wraps).- tuning
Tuning: every number that shapes how the hero moves. Units and seconds (the movement’s space: pixels at a scale of 1; seedocs/scale.md).
Structs§
- World
- The character’s movement: its body, its feel, and the bookkeeping between steps. The
world around it is a
Terrainpassed to everyWorld::step, so it stays yours.
Constants§
- DT
- The fixed simulation step in seconds (120 Hz).