From abc2d4b1f91e952c916b0dd446b6065a4b8550e6 Mon Sep 17 00:00:00 2001 From: dani Date: Sun, 9 Jul 2023 22:37:23 +0000 Subject: [PATCH] target fps parameter to run --- examples/test.rs | 2 +- src/window.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/test.rs b/examples/test.rs index 2ce6bfe..2a50f4e 100644 --- a/examples/test.rs +++ b/examples/test.rs @@ -14,7 +14,7 @@ struct World { fn main() { rand::thread_rng().gen::(); - run::(WIDTH, HEIGHT); + run::(WIDTH, HEIGHT, 240); } impl Game for World { diff --git a/src/window.rs b/src/window.rs index 3ef8514..25d132e 100644 --- a/src/window.rs +++ b/src/window.rs @@ -74,7 +74,7 @@ impl WindowState { } } -pub fn run(width: i32, height: i32) { +pub fn run(width: i32, height: i32, target_fps: u32) { let mut event_loop = EventLoop::new(); let window = { let size = LogicalSize::new(width as f64, height as f64); @@ -109,7 +109,6 @@ pub fn run(width: i32, height: i32) { let mut last_second = Instant::now(); let mut last_frame = last_second; - let target_fps = 60; let target_frame_duration = Duration::from_secs(1) / target_fps; let mut scale = 1usize;