cargo: fmt

This commit is contained in:
Muhammad Nauman Raza 2024-03-22 21:13:08 +00:00
parent a8a342c379
commit f34c4a4803
Signed by: devraza
GPG key ID: 91EAD6081011574B
3 changed files with 26 additions and 22 deletions

View file

@ -57,7 +57,10 @@ fn main() {
.init_resource::<UiState>()
.init_resource::<OpenWindows>()
.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();
}

View file

@ -72,7 +72,7 @@ pub fn attack(
keys: Res<ButtonInput<KeyCode>>,
mut set: ParamSet<(
Query<&mut Transform, With<Attack>>,
Query<&Transform, With<Player>>
Query<&Transform, With<Player>>,
)>,
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() {

View file

@ -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 =