-
- let now = Instant::now();
- accumulator += now - previous_clock;
- previous_clock = now;
-
- let fixed_time_stamp = Duration::new(0, 16666667);
- while accumulator >= fixed_time_stamp {
- accumulator -= fixed_time_stamp;
-
- // if you have a game, update the state here
- }
-
- thread::sleep(fixed_time_stamp - accumulator);