Implement health bar system: add HealthBar class for managing health, integrate health updates in HUDLayer, and modify enemy attack handling to reflect damage taken.

This commit is contained in:
2026-03-30 20:43:06 +00:00
parent 0369d24338
commit 32de437f86
9 changed files with 110 additions and 24 deletions
+3 -1
View File
@@ -6,11 +6,13 @@ class Force < Enemy
def initialize(x, y)
super(x, y, 100)
$bus.on(:occams_razor_attack) do |attack_x, attack_y, range, damage|
$bus.on(:attack) do |attack_x, attack_y, range, damage|
# Whoa, did'nt know ruby had hypot functions built in!
if Math.hypot(@x - attack_x, @y - attack_y) <= range
take_damage(damage)
next true
end
false
end
end
end