hypoloop

Crates.iohypoloop
lib.rshypoloop
version0.1.7
sourcesrc
created_at2021-08-11 19:42:49.065473
updated_at2021-08-13 03:42:52.851674
descriptionA low-level control loop for real-time and baked simulations.
homepage
repositoryhttps://github.com/skyeterran/hypoloop
max_upload_size
id434914
size103,362
Skye Terran (skyeterran)

documentation

README

hypoloop

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

Features:

  • Constant update rate
  • Variable display rate
  • Arbitrary simulation timescale
  • Compatible with other libraries' built-in event loops
  • 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 mut update_logic = move |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_time();
    };
    
    // create a closure containing your display logic
    let display_logic = move |state: &State| {
        //
    };

    // run the simulation with your user-defined update and display logic
    // initialize the sim (cleans internal clocks, etc.)
    sim.init();
    loop {
        // "step" the sim forward
        sim.step(&mut update_logic, &display_logic);
    }
}
Commit count: 51

cargo fmt