improvements

This commit is contained in:
2021-10-21 10:43:13 +02:00
parent deaed7b456
commit c63f7fc556
6 changed files with 36 additions and 24 deletions

View File

@@ -1,11 +1,18 @@
use crate::{input::InputState, text::update_text, vulkan::{PERF_COUNTER_SIZE, VulkanRenderer, gameobject::{GameObject, GameObjectHandle, Updatable}}};
use crate::{input::InputState, text::{create_text_object, update_text}, vulkan::{PERF_COUNTER_SIZE, VulkanRenderer, gameobject::{GameObject, GameObjectHandle, Updatable}}};
use super::GameState;
use super::{GameState, TestGame};
pub struct FpsCounter {
pub game_object: GameObjectHandle
}
impl FpsCounter {
pub fn new(game: &mut TestGame, renderer: &mut VulkanRenderer) -> Box<FpsCounter> {
let text_mesh = create_text_object(&mut game.game_state.brush, renderer, "", 30.);
Box::new(FpsCounter { game_object: game.add_game_object(renderer, text_mesh) })
}
}
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 update_duration = renderer.game_data.update_perf_counters.iter().sum::<u128>() / PERF_COUNTER_SIZE as u128;