fps counter

This commit is contained in:
2021-10-14 22:27:54 +02:00
parent 5365097f3b
commit 989056af99
7 changed files with 160 additions and 142 deletions

14
src/game/components.rs Normal file
View File

@@ -0,0 +1,14 @@
use crate::{input::InputState, text::update_text, vulkan::{VulkanRenderer, gameobject::{GameObject, GameObjectHandle, Updatable}}};
use super::GameState;
pub struct FpsCounter {
pub game_object: GameObjectHandle
}
impl Updatable for FpsCounter {
fn update(&mut self, delta_time: f32, _input: &InputState, game_state: &mut GameState, game_objects: &mut Vec<GameObject>, renderer: &mut VulkanRenderer) {
let text = format!("{}ms\n{}fps", delta_time * 1000., 1. / delta_time);
update_text(self.game_object, &text, 30., renderer, &mut game_state.brush, game_objects)
}
}