From 2e39423d11a6cd1e25b54c30d9afd22e8eff9dfe Mon Sep 17 00:00:00 2001 From: Alexander Foremny Date: Tue, 19 Mar 2024 07:36:54 +0100 Subject: feat: shield ability --- src/client.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/client.rs') 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); } } -- cgit v1.2.3