Skip to content

About

Realm engine lifecycle: fixed-timestep tick loop, scheduler, deterministic RNG

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Realm Runtime

A fixed clock for Rust games that need to run the same simulation in a test and on a server.

Quick start  ·  Scheduler  ·  Tests

use realm_runtime::{DurationExt, Tick, TickLoop, TickRate};

fn main() {
    let rate = TickRate::new(20).unwrap();
    let mut clock = TickLoop::new(rate, 4, |_| {});
    clock.step(10);

    assert_eq!(clock.time().tick, Tick(10));
    assert_eq!(clock.time().elapsed, 500.millis());
}

What is Realm Runtime?

A standalone Rust library for running a game simulation at a fixed tick rate. It provides manual and real-time stepping, ordered systems, lifecycle hooks, and seeded randomness for reproducible runs.

Budget a slow frame

Feed elapsed time to FixedTimestep::advance. At 20 Hz, with a cap of four ticks, a 275 ms frame runs four ticks, drops one and carries 25 ms into the next frame. Accumulator implementation

275 ms at 20 Hz
4 updates + 25 ms carried

PreUpdate → Update
PostUpdate → Replicate

Put input before movement

Register systems on a Scheduler<C> and pass your own state as &mut C. Tick hooks run first, then each stage runs its systems in registration order. Stage and plugin API

Replay a run

Keep a DetRng with the simulation state. Reusing the seed and the sequence of calls reproduces the draws, including integer ranges and probability checks. PCG32 implementation

seed + same draws
↓
same sequence

Features

Clock

  • Nonzero TickRate
  • Tick number, elapsed time and delta

Pacing

  • Fractional tick accumulation
  • Bounded catch-up per frame

Drivers

  • Current-thread real-time loop
  • Manual steps and shared stop flag

Schedule

  • Four standard stages
  • Named systems and custom stages

Lifecycle

  • Boot, Tick and Shutdown hooks
  • Reusable Plugin<C> registrations

Simulation tools

  • Seeded PCG32 and glam math
  • Seconds, milliseconds and tick conversions

Built with

Rust

The clock and thread driver use the standard library. The math module re-exports glam.

Quick start

With Rust 1.99 or newer and Cargo, add the crate to an existing Rust project.

cargo add --git https://github.com/mpge/realm-runtime realm-runtime

Put the example in src/main.rs of a binary crate and run cargo run. Change the rate to see how much simulation time ten ticks cover.

Learn more

Topic Reference
Drive a simulation Tick loop · Time arithmetic
Extend the schedule Builder and plugins · Clock and ordering tests

License

MIT License, copyright © 2026 Matthew Gros.

Realm is an independent project and is not affiliated with or endorsed by Laravel Holdings Inc.

About

Realm engine lifecycle: fixed-timestep tick loop, scheduler, deterministic RNG

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages