Expand description
Ferravex: original, modular Rust engine systems using only project crates and std.
§Make a game
From a Ferravex checkout, three commands give you a playable 2D starter
(add --template 3d for 3D) that depends only on this crate:
python3 -B scripts/ferravex.py new moon-garden
cd ../moon-garden
cargo runIts rules live in src/game.rs and run on fixed ticks; drawing in
src/lib.rs and src/hud.rs only reads them. The same project builds for
the browser with python3 scripts/build-web.py --serve.
§Learn the facade
Start with prelude for session timing, math, cameras and input. Rendering
functions stay under render so their origin remains clear. The full
engine modules remain available for more specialized systems.
§Find an API
The prelude adds only common starting points; qualified paths retain the original types and errors without facade wrappers:
SessionConfigvalidates reusable session settings. Usecore::FixedClockErrorfor setup failures andsession::SessionStepErrorfor rejected inspector ticks fromGameSession::step_paused.app::{App, Game, AppFrameReport}provides a host-driven lifecycle and reports scheduled versus executed updates, including partial failures.time::SimulationTimer,scheduler,events,snapshotsanddiagnosticsprovide explicit timing, bounded work and observability.inputcontains action maps and binding validation;render::inputadapts host input, controls editing and binding hints.gameplay,play::navigation,play::sceneandauthoringcontain game rules and authored content.camerasupplies simulation-independent rigs;render::Camera2Dandrender::Camera3Dconfigure drawing.feedbackproduces responses to accepted events.render::preferencessynchronizes presentation policy;audio::GameAudioowns runtime voices on its creating thread.play::replayprovides generic recording/playback;replay::Replayretains the distinct legacy network-input format.persistencecontains portable records/preferences;render::storageprovides host storage.physicsis the rotating rigid-body API;dynamicsis the separate translational solver. Their world types are not interchangeable.
The facade’s optional content feature forwards runtime authoring support
to the engine. The default facade already exposes renderer-independent
authoring APIs; enabling content is not needed for the example below.
use ferravex::prelude::*;
let config = SessionConfig::try_new(60.0, 8, true)?;
let mut session = GameSession::from_config(config);
let mut position = Vec2::ZERO;
let mut previous = position;
let velocity = vec2(120.0, 0.0);
let frame = session.advance(1.5 / 60.0);
for _ in 0..frame.steps {
previous = position;
position += velocity * frame.dt;
}
// Presentation interpolates snapshots without changing simulation state.
let visible_position = previous.lerp(position, frame.alpha);
assert!((visible_position.x - 1.0).abs() < 0.0001);For drawing, render::shapes provides anti-aliased rounded shapes and glows,
render::ui::kit provides modern panels, buttons and key prompts, and
render::post adds opt-in bloom and grading such as PostFx::subtle().
Run the facade-only example’s deterministic scenario without a display:
cargo run -p ferravex --example quickstart --offline --locked -j 2 -- --headless.
Omit -- --headless for an interactive native window. It demonstrates pause,
restart and paused single-stepping using the existing render::game! entry
point. Compile its Wasm entry point with
cargo build -p ferravex --example quickstart --target wasm32-unknown-unknown --offline --locked -j 2.
Compilation alone does not exercise a browser host or graphics device.
Re-exports§
pub use ferravex_core as core;
Modules§
- ai
- Shared AI plus authoritative current-pose rigid-world occlusion.
- animation
- First-party playback, skeletal/sprite clips, state graphs and retained GPU skinning.
- app
- Host-driven startup, fixed update, presentation and shutdown hooks. A renderer-independent, host-driven application lifecycle.
- assets
- Deterministic cooked bundles with bounded parsing and transactional hot reload.
The original RLE codec is intended for flat-color assets, not general-purpose compression.
Each bundle permits 4096 paths (240 bytes each) and 64 MiB of decoded payload.
Retained Arc readers keep old generations alive; the limit is per bundle, not global.
Checksums detect corruption and provide no authentication or encryption.
Checked lookups normalize authoring paths; legacy operations and the wire format
continue to require canonical paths. Checked live updates validate before publication.
Bundle::manifestexposes sorted, borrowed metadata for tooling without encoding a bundle or copying its payloads. - audio
- Shared first-party audio core; platform output lives in ferravex-render.
- bitset
- See
bitsetfor the system contract and examples. Dense dirty/visibility masks with checked indices and ascending iteration. - camera
- Shared follow, orbit, chase and first-person presentation rigs. Shared presentation rigs and a current-pose rigid-physics obstruction adapter.
- commands
- See
commandsfor the system contract and examples. Deferred host/world mutations at an explicit synchronization boundary. - diagnostics
- See
diagnosticsfor the system contract and examples. Bounded local engine diagnostics with severity filtering and consecutive dedup. Codes are 1..=64 bytes, messages <=1024 bytes; no transport or logging backend. Capacity counts records. Repeated equal records retain first/last host tick. - dynamics
- Original, dependency-free 2D/3D translational rigid-body physics.
- ecs
- Original, dependency-free entity/component storage for small Ferravex games.
- ecs_
commands - Bounded deferred ECS authoring, with buffer-local, epoch-local spawn tokens.
- effects
- Original bounded simulation and shared low-poly GPU effect rendering.
- events
- See
eventsfor the system contract and examples. Bounded FIFO engine events. Capacity counts events, not their owned payload bytes. Overflow is explicit; retained events preserve send order.EventQueue::try_send_batchadmits a whole batch only when every event fits, preserving queued events and the caller’s batch on capacity rejection. - frame_
events - See
frame_eventsfor the system contract and examples. Explicit event visibility boundaries for ordered engine systems. Sends enter a pending buffer; advance publishes it and expires the previous frame. Each buffer holds at mostcapacityevents (total retained count <= 2*capacity). - graphics
- First-party CPU graphics: reusable mesh storage, visibility and low-poly rasterization.
- input
- Shared first-party actions, contexts and binding configuration.
- interpolation
- Two-sample presentation history with explicit holds and discontinuities. Two retained simulation values and caller-selected presentation interpolation.
- math
- Original, dependency-free scalar game mathematics.
- net
- Bounded, versioned network protocol shared by native and browser game clients.
- physics
- Original rigid-body simulation for the recovered Ferravex games.
- play
- Original, dependency-free gameplay systems shared by small Ferravex games. Renderer-independent systems; cameras share the first-party scalar math crate.
- pool
- See
poolfor the system contract and examples. Bounded reusable object slots with generation-checked handles. - prelude
- A deliberately small set of common engine entry points.
- profile
- Bounded telemetry. Register counters once; recording does not allocate. Summary construction clones a bounded name; ids belong to their originating profiler.
- random
- See
randomfor the system contract and examples. Reproducible SplitMix64 streams for engine variation, never cryptography. Forks depend on the original seed and stream ID, independent of parent draws. - render
- Original immediate/retained renderer and platform ABI. Game code, input, geometry and scheduling live in Rust; hosts only bind OS events and GPU submission.
- replay
- resources
- See
resourcesfor the system contract and examples. Typed singleton engine resources without string keys or unsafe downcasts. At most 256 distinct types. Values are host-owned and may have arbitrary size. This single-threaded store does not impose Send/Sync on resources. - scheduler
- See
schedulerfor the system contract and examples. Bounded tick deadlines with deterministic FIFO ties and explicit work limits. IDs belong to their scheduler; tick values are monotonic absolute host ticks. - session
- Shared lifecycle and fixed-timestep coordination for local games. Shared start, pause, retry and fixed-timestep timing for local game sessions.
- shuffle
- See
shufflefor the system contract and examples. Reproducible shuffled index cycles for nonrepeating engine variants. - smoothing
- See
smoothingfor the system contract and examples. Frame-independent scalar and angular presentation smoothing. - snapshots
- See
snapshotsfor the system contract and examples. Bounded monotonic tick snapshots. Hosts own state and interpolation semantics. Failed inserts preserve history; rolling eviction removes only the oldest state. - spatial
- See
spatialfor the system contract and examples. Bounded point buckets for engine interest, selection and proximity queries. IDs are host-owned u64 values. Queries visit at most 4096 cells; an oversized query returns an error instead of partial results. This is not a physics broadphase. UseSpatialGrid::query_intoto reuse caller storage and report omitted matches.SpatialGrid::query_radius_intoandSpatialGrid::query_nearest_intoreturn stored positions ranked by squared distance, then ID, without allocating. - state
- See
statefor the system contract and examples. Deferred lifecycle transitions (loading, running, paused, etc.) with an explicit allow-list. Hosts handle enter/exit work after commit; callbacks only run when explicitly supplied toStateMachine::commit_withorStateMachine::try_commit_with. No state-specific game rules are imposed. - system_
order - See
system_orderfor the system contract and examples. Stable topological ordering for sequential engine stages. No systems execute here. Up to 256 named systems. Among systems whose prerequisites are satisfied, the earliest registered system always runs first, including newly ready systems. - systems
- Prepared, bounded sequential execution over the existing
SystemOrder. - tags
- See
tagsfor the system contract and examples. Bounded hierarchical tags for engine content and system filters. Tags are case-sensitive ASCII segments separated by dots. A stored child satisfies its parent query;render.meshnever matchesrender.meshes. - time
- See
timefor the system contract and examples. Supplied simulation time, pause/scale control, and drift-free duration timers. - weighted
- See
weightedfor the system contract and examples. Checked integer-weight sampling for engine content and procedural variants. - work_
budget - See
work_budgetfor the system contract and examples. Deterministic shared work quotas for AI, streaming and incremental rebuilds. Units are host-defined work items, not inferred CPU time. Requests never partially consume unless the caller explicitly usesWorkBudget::grant_up_to.
Structs§
- Entity
- Opaque slot identity. A despawned entity never becomes valid again in its world. Handles are world-local; two separate worlds may issue the same identity.
- Fixed
Clock - Frame-rate independent simulation with bounded catch-up work.
- Frame
Stats - Allocation-free statistics over the most recent
Naccepted frame times. - Frame
Step - A fixed simulation step budget with a fractional render interpolation factor.
- Game
Session - A local game lifecycle with an owned, deterministic
FixedClock. - Session
Config - Validated, reusable settings for a
GameSession. - Tick
Batch - An allocation-free snapshot of a frame budget and its scheduled tick IDs.
- Tick
Context - Context for one scheduled fixed update, produced by
TickBatch::ticks. - World
- Sparse typed storage with generational entities and checked component borrows.
Enums§
- Session
State - Host lifecycle state, independent of a game’s simulation-specific phases.