From 2c41ea1e6bb5d3168ddd6dc54c706b105ec23234 Mon Sep 17 00:00:00 2001 From: _ <_@_> Date: Sun, 9 Jan 2022 13:49:57 +0000 Subject: [PATCH] :bug: bug: sleep less, to hit 60 FPS --- src/bin/platformer/main.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bin/platformer/main.rs b/src/bin/platformer/main.rs index a89fdc8..c8e97f5 100644 --- a/src/bin/platformer/main.rs +++ b/src/bin/platformer/main.rs @@ -336,19 +336,19 @@ async fn main () -> Result <()> { graphics.draw (&game_state, &mut gl_state, &level, &camera); graphics.frames += 1; - if graphics.frames == next_mpf_print { + if graphics.frames == next_upf_print { let now = Instant::now (); - let mpf = (now - last_mpf_instant).as_millis () / 60; + let upf = (now - last_upf_instant).as_micros () / 60; - dbg! (mpf); + dbg! (upf); - next_mpf_print += 60; - last_mpf_instant = now; + next_upf_print += 60; + last_upf_instant = now; } window.gl_swap_window (); - tokio::time::sleep (Duration::from_millis (15)).await; + tokio::time::sleep (Duration::from_millis (10)).await; } Ok (())