diff options
Diffstat (limited to 'pixel-client/src/profiler.rs')
-rw-r--r-- | pixel-client/src/profiler.rs | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/pixel-client/src/profiler.rs b/pixel-client/src/profiler.rs deleted file mode 100644 index 660c06cd..00000000 --- a/pixel-client/src/profiler.rs +++ /dev/null @@ -1,66 +0,0 @@ -/* - Hurry Curry! - a game about cooking - Copyright (C) 2025 Hurry Curry! Contributors - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, version 3 of the License only. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see <https://www.gnu.org/licenses/>. - -*/ -use crate::render::{sprite::SpriteDraw, Renderer}; -use hurrycurry_protocol::glam::Vec2; -use std::time::Instant; - -pub struct ProfilerOverlay { - frames: usize, - fps_timer_start: Instant, - fps: f32, -} - -impl Default for ProfilerOverlay { - fn default() -> Self { - Self::new() - } -} - -impl ProfilerOverlay { - pub fn new() -> Self { - Self { - fps: 0., - fps_timer_start: Instant::now(), - frames: 0, - } - } - pub fn update(&mut self, renderer: &mut Renderer) { - self.frames += 1; - - let t = self.fps_timer_start.elapsed(); - - if t.as_secs_f32() > 0.2 { - self.fps = self.frames as f32 / t.as_secs_f32(); - self.frames = 0; - self.fps_timer_start += t; - } - let size = renderer.draw_text( - Vec2::ZERO, - &format!("FPS: {:.0}\nSprites: {}", self.fps, renderer.num_sprites()), - 0.3, - Some([255, 150, 255, 255]), - ); - renderer.draw_ui(SpriteDraw::screen( - renderer.misc_textures.solid, - i32::MAX - 1, - Vec2::ZERO, - size, - Some([0, 0, 0, 200]), - )) - } -} |