From 36e0819af5cfe94e39970ed276c3fd387de8616c Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Tue, 17 Sep 2024 10:05:42 +0100 Subject: [PATCH] cargo: fmt --- src/enemy.rs | 2 +- src/helpers.rs | 1 - src/main.rs | 4 ++-- src/ui.rs | 17 ++++++++++------- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/enemy.rs b/src/enemy.rs index a279d1f..0651331 100644 --- a/src/enemy.rs +++ b/src/enemy.rs @@ -1,8 +1,8 @@ use bevy::prelude::*; use std::f32::consts::PI; -use crate::player::*; use crate::helpers::*; +use crate::player::*; // Define the enemy component #[derive(Component)] diff --git a/src/helpers.rs b/src/helpers.rs index 7ae7ef7..dbf15c7 100644 --- a/src/helpers.rs +++ b/src/helpers.rs @@ -15,4 +15,3 @@ pub struct CommonStats { pub mana: f32, pub mana_max: f32, } - diff --git a/src/main.rs b/src/main.rs index a3b6990..5a1b9e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -107,7 +107,7 @@ fn setup(mut commands: Commands, asset_server: Res) { stamina_max: 10., mana: 100., mana_max: 100., - } + }, }); // Spawn an enemy @@ -131,6 +131,6 @@ fn setup(mut commands: Commands, asset_server: Res) { stamina_max: 8., mana: 50., mana_max: 50., - } + }, }); } diff --git a/src/ui.rs b/src/ui.rs index 5d7bef9..cd29e6c 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -116,14 +116,17 @@ pub fn render_ui( egui::Grid::new("Stats") .spacing(egui::Vec2::new(20., 10.)) .show(ui, |ui| { - let health_bar = - egui::widgets::ProgressBar::new(player.stats.health / player.stats.health_max) + let health_bar = egui::widgets::ProgressBar::new( + player.stats.health / player.stats.health_max, + ) + .desired_width(window_width / 10.); + let mut stamina_bar = egui::widgets::ProgressBar::new( + player.stats.stamina / player.stats.stamina_max, + ) + .desired_width(window_width / 10.); + let mana_bar = + egui::widgets::ProgressBar::new(player.stats.mana / player.stats.mana_max) .desired_width(window_width / 10.); - let mut stamina_bar = - egui::widgets::ProgressBar::new(player.stats.stamina / player.stats.stamina_max) - .desired_width(window_width / 10.); - let mana_bar = egui::widgets::ProgressBar::new(player.stats.mana / player.stats.mana_max) - .desired_width(window_width / 10.); // Show the stamina bar to be empty if the player has no stamina if player.stats.stamina <= 0. {