refactor: UI improvements
Former-commit-id: 18ca9fe51ec1419b8e210894f2b299c43905f3a6
This commit is contained in:
parent
a442368f55
commit
1366906f91
|
@ -82,9 +82,9 @@ fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
|
|||
movement_speed: 512.,
|
||||
rotation_speed: f32::to_radians(360.),
|
||||
|
||||
health: 0.4,
|
||||
health: 10.,
|
||||
health_max: 10.,
|
||||
stamina: 0.1,
|
||||
stamina: 10.,
|
||||
stamina_max: 10.,
|
||||
|
||||
defence: 40.,
|
||||
|
|
|
@ -74,10 +74,8 @@ pub fn movement(
|
|||
movement_distance = blink_factor * player.movement_speed * 0.01;
|
||||
}
|
||||
|
||||
// Create the translation using the movement direction and distance
|
||||
let translation_delta = movement_direction * movement_distance;
|
||||
// Update the player translation with the created translation
|
||||
transform.translation += translation_delta;
|
||||
// Update the player translation with the translation
|
||||
transform.translation += movement_direction * movement_distance;
|
||||
|
||||
// Define the bounds of play (the window size)
|
||||
let window = windows.single_mut();
|
||||
|
|
31
src/ui.rs
31
src/ui.rs
|
@ -50,6 +50,12 @@ pub fn render_ui(
|
|||
|
||||
let ctx = contexts.ctx_mut();
|
||||
|
||||
let purple = HYPERNOVA.get("PURPLE").unwrap();
|
||||
let purple = egui::Color32::from_rgb(purple.0, purple.1, purple.2);
|
||||
|
||||
let black = HYPERNOVA.get("BLACK").unwrap();
|
||||
let black = egui::Color32::from_rgb(black.0, black.1, black.2);
|
||||
|
||||
egui::Window::new("Login")
|
||||
.anchor(egui::Align2::CENTER_CENTER, egui::Vec2::new(0., 0.))
|
||||
.resizable(false)
|
||||
|
@ -60,12 +66,6 @@ pub fn render_ui(
|
|||
ui.set_height(window_height / 3.);
|
||||
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::Center), |ui| {
|
||||
let purple = HYPERNOVA.get("PURPLE").unwrap();
|
||||
let purple = egui::Color32::from_rgb(purple.0, purple.1, purple.2);
|
||||
|
||||
let black = HYPERNOVA.get("BLACK").unwrap();
|
||||
let black = egui::Color32::from_rgb(black.0, black.1, black.2);
|
||||
|
||||
// Define spacing between items (widgets) and add manually add some space
|
||||
// between the window border and the heading
|
||||
ui.spacing_mut().item_spacing = egui::vec2(0., 10.);
|
||||
|
@ -108,11 +108,24 @@ pub fn render_ui(
|
|||
..default()
|
||||
})
|
||||
.show(ctx, |ui| {
|
||||
ui.visuals_mut().menu_rounding = egui::Rounding::ZERO;
|
||||
ui.visuals_mut().selection.bg_fill = purple;
|
||||
|
||||
let health = egui::widgets::ProgressBar::new(player.health)
|
||||
.desired_width(window_width / 10.);
|
||||
let defence = egui::widgets::ProgressBar::new(player.defence)
|
||||
let stamina = egui::widgets::ProgressBar::new(player.stamina)
|
||||
.desired_width(window_width / 10.);
|
||||
ui.add(health);
|
||||
ui.add(defence);
|
||||
|
||||
egui::Grid::new("Stats")
|
||||
.spacing(egui::Vec2::new(20., 10.))
|
||||
.show(ui, |ui| {
|
||||
ui.label(egui::RichText::new("Health").color(purple));
|
||||
ui.add(health);
|
||||
ui.end_row();
|
||||
|
||||
ui.label(egui::RichText::new("Stamina").color(purple));
|
||||
ui.add(stamina);
|
||||
ui.end_row();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Reference in a new issue