0.15.1, fps

This commit is contained in:
StephenAdamson
2025-01-16 21:35:04 +00:00
parent d2e9bb0cf3
commit 7b8142afd2
3 changed files with 112 additions and 97 deletions
+15
View File
@@ -10,6 +10,8 @@ mod tile;
mod tilemap;
mod tiles;
use bevy::diagnostic::FrameTimeDiagnosticsPlugin;
fn main() {
App::new()
.insert_resource(game::ZIndex(0.0))
@@ -24,6 +26,7 @@ fn main() {
})
.set(ImagePlugin::default_nearest()),
)
.add_plugins(FrameTimeDiagnosticsPlugin::default()) // Add the FrameTimeDiagnosticsPlugin here
.insert_resource(ClearColor(Color::srgb(0.0, 0.0, 0.0)))
.add_plugins(tilemap::TilemapPlugin)
.add_systems(
@@ -50,7 +53,19 @@ fn main() {
tile::camera_z_movement,
tile::update_tile_visibility
.run_if(|camera_moved: Res<tile::CameraMoved>| camera_moved.0),
log_fps_system,
),
)
.run();
}
use bevy::diagnostic::DiagnosticsStore;
fn log_fps_system(diagnostics: Res<DiagnosticsStore>) {
if let Some(fps) = diagnostics
.get(&FrameTimeDiagnosticsPlugin::FPS)
.and_then(|fps_diagnostic| fps_diagnostic.average())
{
println!("Average FPS: {:.2}", fps);
}
}