ferravex/lib.rs
1//! Ferravex: original, modular Rust engine systems using only project crates and std.
2//!
3//! # Make a game
4//!
5//! From a Ferravex checkout, three commands give you a playable 2D starter
6//! (add `--template 3d` for 3D) that depends only on this crate:
7//!
8//! ```sh
9//! python3 -B scripts/ferravex.py new moon-garden
10//! cd ../moon-garden
11//! cargo run
12//! ```
13//!
14//! Its rules live in `src/game.rs` and run on fixed ticks; drawing in
15//! `src/lib.rs` and `src/hud.rs` only reads them. The same project builds for
16//! the browser with `python3 scripts/build-web.py --serve`.
17//!
18//! # Learn the facade
19//!
20//! Start with [`prelude`] for session timing, math, cameras and input. Rendering
21//! functions stay under [`render`] so their origin remains clear. The full
22//! engine modules remain available for more specialized systems.
23//!
24//! # Find an API
25//!
26//! The prelude adds only common starting points; qualified paths retain the
27//! original types and errors without facade wrappers:
28//!
29//! - [`SessionConfig`] validates reusable session settings. Use
30//! [`core::FixedClockError`] for setup failures and [`session::SessionStepError`]
31//! for rejected inspector ticks from [`GameSession::step_paused`].
32//! - [`app::{App, Game, AppFrameReport}`](app) provides a host-driven lifecycle
33//! and reports scheduled versus executed updates, including partial failures.
34//! - [`time::SimulationTimer`], [`scheduler`], [`events`], [`snapshots`] and
35//! [`diagnostics`] provide explicit timing, bounded work and observability.
36//! - [`input`] contains action maps and binding validation; [`render::input`]
37//! adapts host input, controls editing and binding hints.
38//! - [`gameplay`], [`play::navigation`], [`play::scene`] and [`authoring`] contain
39//! game rules and authored content. [`camera`] supplies simulation-independent
40//! rigs; [`render::Camera2D`] and [`render::Camera3D`] configure drawing.
41//! - [`feedback`] produces responses to accepted events. [`render::preferences`]
42//! synchronizes presentation policy; [`audio::GameAudio`] owns runtime voices
43//! on its creating thread.
44//! - [`play::replay`] provides generic recording/playback; [`replay::Replay`]
45//! retains the distinct legacy network-input format. [`persistence`] contains
46//! portable records/preferences; [`render::storage`] provides host storage.
47//! - [`physics`] is the rotating rigid-body API; [`dynamics`] is the separate
48//! translational solver. Their world types are not interchangeable.
49//!
50//! The facade's optional `content` feature forwards runtime authoring support
51//! to the engine. The default facade already exposes renderer-independent
52//! [`authoring`] APIs; enabling `content` is not needed for the example below.
53//!
54//! ```
55//! use ferravex::prelude::*;
56//!
57//! let config = SessionConfig::try_new(60.0, 8, true)?;
58//! let mut session = GameSession::from_config(config);
59//! let mut position = Vec2::ZERO;
60//! let mut previous = position;
61//! let velocity = vec2(120.0, 0.0);
62//! let frame = session.advance(1.5 / 60.0);
63//! for _ in 0..frame.steps {
64//! previous = position;
65//! position += velocity * frame.dt;
66//! }
67//! // Presentation interpolates snapshots without changing simulation state.
68//! let visible_position = previous.lerp(position, frame.alpha);
69//! assert!((visible_position.x - 1.0).abs() < 0.0001);
70//! # Ok::<(), ferravex::core::FixedClockError>(())
71//! ```
72//!
73//! For drawing, [`render::shapes`] provides anti-aliased rounded shapes and glows,
74//! [`render::ui::kit`] provides modern panels, buttons and key prompts, and
75//! [`render::post`] adds opt-in bloom and grading such as `PostFx::subtle()`.
76//!
77//! Run the facade-only example's deterministic scenario without a display:
78//! `cargo run -p ferravex --example quickstart --offline --locked -j 2 -- --headless`.
79//! Omit `-- --headless` for an interactive native window. It demonstrates pause,
80//! restart and paused single-stepping using the existing [`render::game!`] entry
81//! point. Compile its Wasm entry point with
82//! `cargo build -p ferravex --example quickstart --target wasm32-unknown-unknown --offline --locked -j 2`.
83//! Compilation alone does not exercise a browser host or graphics device.
84pub use ferravex_core as core;
85pub use ferravex_core::session::{GameSession, SessionConfig, SessionState};
86pub use ferravex_core::{Entity, FixedClock, FrameStats, FrameStep, TickBatch, TickContext, World};
87pub use ferravex_engine::*;
88
89pub mod prelude;