Low-level simulation loop
Go to file
2021-08-12 11:00:13 -07:00
examples Added display callback, restoring full functionality 2021-08-12 10:52:21 -07:00
src Added display callback, restoring full functionality 2021-08-12 10:52:21 -07:00
.gitattributes Initial commit 2021-08-05 22:13:39 -07:00
.gitignore updating gitignores, adding example 2021-08-11 12:52:44 -07:00
Cargo.toml Added display callback, restoring full functionality 2021-08-12 10:52:21 -07:00
LICENSE Create LICENSE 2021-08-10 14:05:01 -07:00
README.md Update README.md 2021-08-12 11:00:13 -07:00

hypoloop

A flexible game-like loop for real-time simulation and rendering

Features:

  • Constant update rate
  • Variable display rate
  • Arbitrary simulation timescale
  • Real-time can be disabled for high-speed simulations

Example

use hypoloop::core::{State, Loop};

fn main() {
    // create sim with default configuration
    let mut sim = Loop::new();

    // test variable
    let mut x: f32 = 0.0;

    // create a closure containing your update logic
    let update_logic = |state: &mut State| {    
        // access loop metadata via the State object    
        x += state.get_timescale();
        print!("x: {} | ", x);

        // print information about the current tick's timings
        state.debug_tick();
    };

    // create a closure containing your display logic
    let display_logic = |state: &State| {
        //
    };

    // run the simulation with your user-defined update and display logic
    sim.run(update_logic, display_logic);
}