From 8a1b482b3e89f64e1986763c418ce2e2eccf45bb Mon Sep 17 00:00:00 2001 From: skyeshroom <61299664+skyeshroom@users.noreply.github.com> Date: Thu, 12 Aug 2021 11:01:34 -0700 Subject: [PATCH] Update basics.rs --- examples/basics.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/basics.rs b/examples/basics.rs index 0b489f5..e3d8d08 100644 --- a/examples/basics.rs +++ b/examples/basics.rs @@ -1,24 +1,27 @@ use hypoloop::core::{State, Loop}; -// look into using closures for this fn main() { - // create sim and configure it + // create sim with default configuration let mut sim = Loop::new(); // test variable let mut x: f32 = 0.0; - let update_logic = |state: &mut State| { + // 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| { - // put all display logic here + // }; - // run the simulation using custom update and display logic + // run the simulation with your user-defined update and display logic sim.run(update_logic, display_logic); } \ No newline at end of file