cargo: fmt
This commit is contained in:
parent
a8a342c379
commit
f34c4a4803
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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 =
|
||||
|
|
Reference in a new issue