Added display callback, restoring full functionality

This commit is contained in:
skyeshroom
2021-08-12 10:52:21 -07:00
parent 1801cb9d80
commit 4faaf7d2c1
4 changed files with 17 additions and 13 deletions

View File

@@ -1,20 +1,24 @@
use hypoloop::core::Loop;
use hypoloop::core::{State, Loop};
// look into using closures for this
fn main() {
// create sim and configure it
let mut sim = Loop::new();
//sim.set_realtime(false);
// test variable
let mut x: f32 = 0.0;
// run the simulation using custom update logic
sim.run(|state| {
state.debug_tick();
x += 2.0 * state.get_timescale();
let update_logic = |state: &mut State| {
x += state.get_timescale();
print!("x: {} | ", x);
//println!("Delta time: {} | Timescale: {} | Sim time: {} | x: {}", state.get_delta_time(), state.get_timescale(), state.get_sim_time().as_millis(), x);
});
state.debug_tick();
};
let display_logic = |state: &State| {
// put all display logic here
};
// run the simulation using custom update and display logic
sim.run(update_logic, display_logic);
}