target fps parameter to run

This commit is contained in:
dani 2023-07-09 22:37:23 +00:00
parent b528c6adbe
commit abc2d4b1f9
2 changed files with 2 additions and 3 deletions

View File

@ -14,7 +14,7 @@ struct World {
fn main() {
rand::thread_rng().gen::<Direction>();
run::<World>(WIDTH, HEIGHT);
run::<World>(WIDTH, HEIGHT, 240);
}
impl Game for World {

View File

@ -74,7 +74,7 @@ impl WindowState {
}
}
pub fn run<T: Game + 'static>(width: i32, height: i32) {
pub fn run<T: Game + 'static>(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<T: Game + 'static>(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;