diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-03-19 07:36:54 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-03-19 07:36:54 +0100 |
commit | 2e39423d11a6cd1e25b54c30d9afd22e8eff9dfe (patch) | |
tree | 204e0bfc8f69c1ca57daa449b1eed723e43ef40c /src/client.rs | |
parent | 9d8bf0fde7b12fa77569333d17f310e55df58db9 (diff) |
feat: shield ability
Diffstat (limited to 'src/client.rs')
-rw-r--r-- | src/client.rs | 12 |
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); } } |