From f70f79e96af2f4e931c6ea9bb6401f1050a62153 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 25 Jan 2024 21:25:21 -0800 Subject: [PATCH] Added last run to renderinput --- crates/galactica/src/main.rs | 4 ++++ crates/render/src/renderinput.rs | 3 +++ 2 files changed, 7 insertions(+) diff --git a/crates/galactica/src/main.rs b/crates/galactica/src/main.rs index 9e1ed2f..bd78918 100644 --- a/crates/galactica/src/main.rs +++ b/crates/galactica/src/main.rs @@ -21,6 +21,7 @@ use nalgebra::Vector2; use std::{ fs, path::{Path, PathBuf}, + time::Instant, }; use winit::{ event::{Event, KeyboardInput, WindowEvent}, @@ -132,6 +133,7 @@ fn try_main() -> Result<()> { ); let mut phys_img = PhysImage::new(); + let mut last_run = Instant::now(); event_loop.run(move |event, _, control_flow| { match event { @@ -143,9 +145,11 @@ fn try_main() -> Result<()> { ct: &content, phys_img: &phys_img, player: &player, + time_since_last_run: last_run.elapsed().as_secs_f32(), current_system: SystemHandle { index: 0 }, timing: game.get_timing().clone(), }; + last_run = Instant::now(); match gpu.render(render_input) { Ok(_) => {} diff --git a/crates/render/src/renderinput.rs b/crates/render/src/renderinput.rs index d62c82e..a017651 100644 --- a/crates/render/src/renderinput.rs +++ b/crates/render/src/renderinput.rs @@ -25,6 +25,9 @@ pub struct RenderInput<'a> { /// The current time, in seconds pub current_time: f32, + /// The amount of time that has passed since the last frame was drawn + pub time_since_last_run: f32, + /// Game content pub ct: &'a Content,