Update basics.rs
This commit is contained in:
parent
74c7b3188d
commit
8a1b482b3e
@ -1,24 +1,27 @@
|
|||||||
use hypoloop::core::{State, Loop};
|
use hypoloop::core::{State, Loop};
|
||||||
|
|
||||||
// look into using closures for this
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// create sim and configure it
|
// create sim with default configuration
|
||||||
let mut sim = Loop::new();
|
let mut sim = Loop::new();
|
||||||
|
|
||||||
// test variable
|
// test variable
|
||||||
let mut x: f32 = 0.0;
|
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();
|
x += state.get_timescale();
|
||||||
print!("x: {} | ", x);
|
print!("x: {} | ", x);
|
||||||
|
|
||||||
|
// print information about the current tick's timings
|
||||||
state.debug_tick();
|
state.debug_tick();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// create a closure containing your display logic
|
||||||
let display_logic = |state: &State| {
|
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);
|
sim.run(update_logic, display_logic);
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user