From 74c7b3188d9d440824088e2f49762815265c13ab Mon Sep 17 00:00:00 2001 From: Skye Terran Date: Thu, 12 Aug 2021 11:00:13 -0700 Subject: [PATCH] Update README.md --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index 6c04c60..b2229ba 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,34 @@ - Variable display rate - Arbitrary simulation timescale - Real-time can be disabled for high-speed simulations + +## Example +```rust +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 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| { + // + }; + + // run the simulation with your user-defined update and display logic + sim.run(update_logic, display_logic); +} +```