Added display callback, restoring full functionality
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user