cargo: fmt
This commit is contained in:
parent
a8a342c379
commit
f34c4a4803
|
@ -57,7 +57,10 @@ fn main() {
|
||||||
.init_resource::<UiState>()
|
.init_resource::<UiState>()
|
||||||
.init_resource::<OpenWindows>()
|
.init_resource::<OpenWindows>()
|
||||||
.add_systems(Startup, (setup, setup_ui))
|
.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();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ pub fn attack(
|
||||||
keys: Res<ButtonInput<KeyCode>>,
|
keys: Res<ButtonInput<KeyCode>>,
|
||||||
mut set: ParamSet<(
|
mut set: ParamSet<(
|
||||||
Query<&mut Transform, With<Attack>>,
|
Query<&mut Transform, With<Attack>>,
|
||||||
Query<&Transform, With<Player>>
|
Query<&Transform, With<Player>>,
|
||||||
)>,
|
)>,
|
||||||
mut player_query: Query<&mut Player>,
|
mut player_query: Query<&mut Player>,
|
||||||
mut commands: Commands,
|
mut commands: Commands,
|
||||||
|
@ -81,26 +81,27 @@ pub fn attack(
|
||||||
let mut player = player_query.single_mut();
|
let mut player = player_query.single_mut();
|
||||||
|
|
||||||
for player_transform in set.p1().iter_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) {
|
if keys.just_pressed(KeyCode::Enter) {
|
||||||
commands
|
commands
|
||||||
.spawn(SpriteBundle {
|
.spawn(SpriteBundle {
|
||||||
texture: asset_server.load("attacks/stone_cannon.png"),
|
texture: asset_server.load("attacks/stone_cannon.png"),
|
||||||
transform: Transform {
|
transform: Transform {
|
||||||
scale: Vec3::splat(0.3),
|
scale: Vec3::splat(0.3),
|
||||||
translation: attack_position,
|
translation: attack_position,
|
||||||
rotation: player_transform.rotation,
|
rotation: player_transform.rotation,
|
||||||
},
|
},
|
||||||
..default()
|
..default()
|
||||||
})
|
})
|
||||||
.insert(Attack {
|
.insert(Attack {
|
||||||
velocity: 10.,
|
velocity: 10.,
|
||||||
damage: 20.,
|
damage: 20.,
|
||||||
});
|
});
|
||||||
|
|
||||||
player.mana -= 1.;
|
player.mana -= 1.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for mut attack_transform in set.p0().iter_mut() {
|
for mut attack_transform in set.p0().iter_mut() {
|
||||||
|
|
|
@ -118,12 +118,12 @@ pub fn render_ui(
|
||||||
.show(ui, |ui| {
|
.show(ui, |ui| {
|
||||||
let health_bar = egui::widgets::ProgressBar::new(player.health)
|
let health_bar = egui::widgets::ProgressBar::new(player.health)
|
||||||
.desired_width(window_width / 10.);
|
.desired_width(window_width / 10.);
|
||||||
let mut stamina_bar = egui::widgets::ProgressBar::new(player.stamina / player.stamina_max)
|
let mut stamina_bar =
|
||||||
.desired_width(window_width / 10.);
|
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)
|
let mana_bar = egui::widgets::ProgressBar::new(player.mana / player.mana_max)
|
||||||
.desired_width(window_width / 10.);
|
.desired_width(window_width / 10.);
|
||||||
|
|
||||||
|
|
||||||
// Show the stamina bar to be empty if the player has no stamina
|
// Show the stamina bar to be empty if the player has no stamina
|
||||||
if player.stamina <= 0. {
|
if player.stamina <= 0. {
|
||||||
stamina_bar =
|
stamina_bar =
|
||||||
|
|
Reference in a new issue