hypoloop/README.md

44 lines
1.1 KiB
Markdown
Raw Normal View History

2021-08-10 15:18:59 -06:00
# hypoloop
2021-08-10 15:12:36 -06:00
## A flexible game-like loop for real-time simulation and rendering
2021-08-10 15:17:51 -06:00
### Features:
- Constant update rate
- Variable display rate
- Arbitrary simulation timescale
2021-08-11 12:57:13 -06:00
- Real-time can be disabled for high-speed simulations
2021-08-12 12:00:13 -06:00
## 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 mut update_logic = move |state: &mut State| {
2021-08-12 12:00:13 -06:00
// access loop metadata via the State object
x += state.get_timescale();
print!("x: {} | ", x);
// print information about the current tick's timings
state.debug_time();
2021-08-12 12:00:13 -06:00
};
2021-08-12 12:00:13 -06:00
// create a closure containing your display logic
let display_logic = move |state: &State| {
2021-08-12 12:00:13 -06:00
//
};
// run the simulation with your user-defined update and display logic
// initialize the sim (cleans internal clocks, etc.)
sim.init();
loop {
// "step" the sim forward
sim.step(&mut update_logic, &display_logic);
}
2021-08-12 12:00:13 -06:00
}
```