From f34c4a48031d631bdda17f0d0a78001f890e8d3f Mon Sep 17 00:00:00 2001 From: Muhammad Nauman Raza Date: Fri, 22 Mar 2024 21:13:08 +0000 Subject: [PATCH] cargo: fmt --- src/main.rs | 5 ++++- src/player.rs | 37 +++++++++++++++++++------------------ src/ui.rs | 6 +++--- 3 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/main.rs b/src/main.rs index fdf1f09..0d20726 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,10 @@ fn main() { .init_resource::() .init_resource::() .add_systems(Startup, (setup, setup_ui)) - .add_systems(Update, (render_ui, movement, camera_follow, player_regen, attack)) + .add_systems( + Update, + (render_ui, movement, camera_follow, player_regen, attack), + ) .run(); } diff --git a/src/player.rs b/src/player.rs index 0c8ed18..a05ae11 100644 --- a/src/player.rs +++ b/src/player.rs @@ -72,7 +72,7 @@ pub fn attack( keys: Res>, mut set: ParamSet<( Query<&mut Transform, With>, - Query<&Transform, With> + Query<&Transform, With>, )>, mut player_query: Query<&mut Player>, mut commands: Commands, @@ -81,26 +81,27 @@ pub fn attack( let mut player = player_query.single_mut(); for player_transform in set.p1().iter_mut() { - let attack_position = player_transform.translation + ((player_transform.rotation * Vec3::Y) * 100.); + let attack_position = + player_transform.translation + ((player_transform.rotation * Vec3::Y) * 100.); if keys.just_pressed(KeyCode::Enter) { - commands - .spawn(SpriteBundle { - texture: asset_server.load("attacks/stone_cannon.png"), - transform: Transform { - scale: Vec3::splat(0.3), - translation: attack_position, - rotation: player_transform.rotation, - }, - ..default() - }) - .insert(Attack { - velocity: 10., - damage: 20., - }); + commands + .spawn(SpriteBundle { + texture: asset_server.load("attacks/stone_cannon.png"), + transform: Transform { + scale: Vec3::splat(0.3), + translation: attack_position, + rotation: player_transform.rotation, + }, + ..default() + }) + .insert(Attack { + velocity: 10., + damage: 20., + }); - player.mana -= 1.; - } + player.mana -= 1.; + } } for mut attack_transform in set.p0().iter_mut() { diff --git a/src/ui.rs b/src/ui.rs index 7c76359..5450d69 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -118,12 +118,12 @@ pub fn render_ui( .show(ui, |ui| { let health_bar = egui::widgets::ProgressBar::new(player.health) .desired_width(window_width / 10.); - let mut stamina_bar = egui::widgets::ProgressBar::new(player.stamina / player.stamina_max) - .desired_width(window_width / 10.); + let mut stamina_bar = + egui::widgets::ProgressBar::new(player.stamina / player.stamina_max) + .desired_width(window_width / 10.); let mana_bar = egui::widgets::ProgressBar::new(player.mana / player.mana_max) .desired_width(window_width / 10.); - // Show the stamina bar to be empty if the player has no stamina if player.stamina <= 0. { stamina_bar =