| Crates.io | game_clock |
| lib.rs | game_clock |
| version | 1.1.1 |
| created_at | 2020-11-17 17:05:58.402786+00 |
| updated_at | 2021-04-11 20:34:32.898694+00 |
| description | Provides a clock for game (engines) that is simple to use and efficient. |
| homepage | |
| repository | https://git.jojolepro.com/game_clock/ |
| max_upload_size | |
| id | 313340 |
| size | 21,269 |
Support an Open Source Developer! :hearts:

Read the documentation.
Add the following to you Cargo.toml file:
game_clock = "*"
Use the clock like so:
use game_clock::Time;
use std::time::Duration;
fn main() {
let mut time = Time::default();
time.set_fixed_time(Duration::from_secs_f64(1.0 / 20.0));
let step = 1.0 / 60.0;
for _ in 0..60 {
time.advance_frame(Duration::from_secs_f64(step));
{ } // ...Run game logic, rendering, etc...
while time.step_fixed_update() { // runs 20 times in a frame.
{ } // Run fixed frame logic (ie. physics)
}
}
}