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:
+3
-1
@@ -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
|
||||
Reference in New Issue
Block a user