aboutsummaryrefslogtreecommitdiffstats
path: root/src/client.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client.rs')
-rw-r--r--src/client.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/client.rs b/src/client.rs
index 5084eaa..8da77dc 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -522,11 +522,13 @@ fn render_health(players: Query<(&Health, &PlayerPosition, &EffectiveStats)>, mu
for (health, position, effective_stats) in players.iter() {
let start = position.0 + Vec2::new(-PLAYER_RADIUS, PLAYER_RADIUS + HEALTH_OFFSET);
let end = position.0 + Vec2::new(PLAYER_RADIUS, PLAYER_RADIUS + HEALTH_OFFSET);
- gizmos.line_2d(
- start,
- start.lerp(end, health.0 / effective_stats.0.max_health),
- Color::RED,
- );
+ let health_start = start;
+ let health_end = start.lerp(end, health.health / effective_stats.0.max_health);
+ let px_per_health = (end.x - start.x) / effective_stats.0.max_health;
+ let shield_start = health_end;
+ let shield_end = health_end + Vec2::new(health.shield * px_per_health, 0.);
+ gizmos.line_2d(health_start, health_end, Color::RED);
+ gizmos.line_2d(shield_start, shield_end, Color::GRAY);
}
}