Skip to main content

Crate rayengine

Crate rayengine 

Source
Expand description

§rayengine

A small Linux-first Rust game SDK over raylib. Games are ordinary Cargo projects with a shared lifecycle for 2D and 3D, action input, fixed updates, fitted cameras, logical UI with optional interaction and explicit asset ownership. Version 0.0.1.

Start with the quickstart, then read game structure and optional plugins. The remaining guides explain responsive viewports, timing and input, assets, first-person movement, generated meshes, materials and shaders, spatial queries, background work, interactive UI and input routing, versioned saves, runtime diagnostics, testing and performance, and the agent workflow.

rayengine-core contains display-independent components and math; access it through core or depend on it directly for simulations without raylib. prelude contains the normal game imports. raylib remains available for specialized rendering and other lower-level features.

use rayengine::prelude::*;

#[derive(Default)]
struct Hello;

impl Game for Hello {
    fn fixed_update(&mut self, _: &mut Update<'_, '_>) {}
    fn draw(&mut self, frame: &mut Frame<'_, '_>) {
        frame.clear(Color::new(18, 29, 48, 255));
        frame.world_2d(Camera2D::default(), |canvas| {
            canvas.circle(Vec2::ZERO, 40.0, Color::SKYBLUE);
        });
        frame.ui(|ui| ui.text("Hello, rayengine", Vec2::new(24.0, 24.0), 24.0, Color::WHITE));
    }
}

fn main() -> Result<(), Error> {
    App::new(Config::new("Hello")).run(Hello)?;
    Ok(())
}

The first release provides basic swept character movement and geometric drawing, not rigid-body dynamics or an advanced 3D rendering pipeline. The interactive input/image/state testing protocol is deferred. The CLI’s JSON project diagnostics are available now. Desktop Linux is the supported development target; Windows and macOS are optional and not yet verified by this project’s CI.

Re-exports§

pub use plugin::Plugin;
pub use runtime::App;
pub use runtime::Config;
pub use runtime::CursorMode;
pub use runtime::Error;
pub use runtime::Game;
pub use runtime::InitContext;
pub use runtime::RunOptions;
pub use runtime::RunReport;
pub use runtime::Update;
pub use rayengine_core as core;
pub use raylib;

Modules§

assets
Cached asset ownership with typed stable handles and explicit unloading.
diagnostics
Opt-in, bounded runtime summaries. Timings are CPU wall times, not GPU timers.
first_person
Optional first-person movement over Body3D. Games own worlds, spawning, checkpoints, menus, interaction and input-edge consumption.
guides
Guides authored in Markdown and exported to HTML by rustdoc.
input
Physical bindings sampled once per render frame into shared action states.
material
Reusable surface descriptions and cached, typed shader parameters.
plugin
Optional, statically typed extensions composed by a game.
prelude
Common imports for a game using the prescribed lifecycle.
render
Immediate drawing with corresponding 2D/3D passes and shared logical UI.
runtime
Window lifecycle: initialize once, sample input, fixed-update, draw, present.
save
Versioned, checksummed containers for game-defined payloads.
upload
Bounded CPU mesh staging and explicit render-thread upload budgets.