diff --git a/Cargo.lock b/Cargo.lock index f50b6d8..8997931 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5055,7 +5055,7 @@ dependencies = [ [[package]] name = "turtle_time" -version = "0.7.2" +version = "0.7.3" dependencies = [ "bevy", "bevy-inspector-egui", diff --git a/Cargo.toml b/Cargo.toml index 3df831c..de973dc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "turtle_time" -version = "0.7.2" +version = "0.7.3" publish = false authors = ["Mike Eder "] # ToDo: you are the author edition = "2021" diff --git a/src/main.rs b/src/main.rs index 4109e05..475d709 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,7 @@ fn main() { .build(&mut app); app.insert_resource(Msaa::Off) - .insert_resource(ClearColor(Color::rgb(0.4, 0.4, 0.4))) + .insert_resource(ClearColor(Color::rgb(0.0, 0.3, 0.0))) .add_plugins( DefaultPlugins .set(WindowPlugin { diff --git a/src/player/systems.rs b/src/player/systems.rs index b6e54b4..7064fda 100644 --- a/src/player/systems.rs +++ b/src/player/systems.rs @@ -904,6 +904,7 @@ pub fn add_player_health_bars( commands.entity(health_entity).with_children(|cb| { cb.spawn(SpriteBundle { + // black background sprite: Sprite { color: Color::BLACK, custom_size: Some(Vec2::new(PLAYER_HEALTH_MAX as f32, TILE_SIZE / 4.)), @@ -915,9 +916,10 @@ pub fn add_player_health_bars( .with_children(|parent| { parent .spawn(SpriteBundle { + // red overlay sprite: Sprite { color: Color::RED, - custom_size: Some(Vec2::new(PLAYER_HEALTH_MAX as f32, TILE_SIZE / 4.)), + custom_size: Some(Vec2::new(PLAYER_HEALTH_MAX as f32, TILE_SIZE / 8.)), ..default() }, transform: Transform::from_xyz(0., 0., 0.2), @@ -940,6 +942,10 @@ pub fn update_health_bars( for (_, health_bar, mut transform) in bars { let player_health = health_entities.get(health_bar.health_entity).unwrap(); let health_percent = player_health.decimal(); + let h = PLAYER_HEALTH_MAX as f32 * 0.5; + let x_offset = h - h * health_percent; + transform.scale = vec3(health_percent as f32, 1.0, 1.0); + transform.translation = vec3(-x_offset, 0., 0.2) } }