From 9035b14fd2ef35b883a8a62845fbf18e891fefb8 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 11 Nov 2025 17:35:11 -0500 Subject: graphics: use custom timer for delta_time/fps --- graphics/src/lib.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'graphics/src/lib.rs') diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs index 8dccd63..43bf3ac 100644 --- a/graphics/src/lib.rs +++ b/graphics/src/lib.rs @@ -1,6 +1,8 @@ //! The `graphics` crate contains the core functionality for //! rendering using the `raylib` library. +use std::time::Duration; + use dungeon::Dungeon; use raylib::prelude::*; @@ -9,6 +11,7 @@ use crate::render::Renderer; mod audio; mod render; +mod timer; /// The `Error` type used within this crate pub type Error = Box; @@ -77,7 +80,6 @@ impl From for KeyboardKey { } /// The `WindowBuilder` type allows setting partial options for the window -#[derive(Debug)] pub struct WindowBuilder<'a> { title: &'a str, width: u16, @@ -182,7 +184,6 @@ impl Default for WindowBuilder<'_> { } /// The `Window` type represents the game window -#[derive(Debug)] pub struct Window { // persistant renderer renderer: Renderer, @@ -211,8 +212,8 @@ impl Window { } /// Returns the per frame delta time - pub fn delta_time(&self) -> f32 { - self.handle.get_frame_time() + pub fn delta_time(&self) -> Duration { + self.renderer.delta_time() } /// Returns if the provided `Key` has just been pressed -- cgit v1.2.3-freya