hypoloop/examples/basics.rs

32 lines
883 B
Rust
Raw Normal View History

use hypoloop::core::{State, Loop};
2021-08-11 14:21:12 -06:00
2021-08-11 13:52:44 -06:00
fn main() {
2021-08-12 12:01:34 -06:00
// create sim with default configuration
let mut sim = Loop::new();
2021-08-11 14:21:12 -06:00
// test variable
let mut x: f32 = 0.0;
2021-08-11 20:20:26 -06:00
2021-08-12 12:01:34 -06:00
// create a closure containing your update logic
let mut update_logic = move |state: &mut State| {
2021-08-12 12:01:34 -06:00
// access loop metadata via the State object
x += state.get_timescale();
print!("x: {} | ", x);
2021-08-12 12:01:34 -06:00
// print information about the current tick's timings
state.debug_time();
};
2021-08-12 12:01:34 -06:00
// create a closure containing your display logic
let display_logic = move |state: &State| {
2021-08-12 12:01:34 -06:00
//
};
2021-08-12 12:01:34 -06:00
// 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);
}
2021-08-11 20:20:26 -06:00
}