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
+10 -2
View File
@@ -20,8 +20,16 @@ class WeaponHandler
return unless @weapons.key?(selected_item)
weapon = @weapons[selected_item]
if $bus.get(:count, selected_item) > 0 && Gosu.button_down?(Gosu::KB_SPACE)
weapon.attack
if $bus.get(:count, selected_item) > 0
if Gosu.button_down?(Gosu::KB_SPACE)
direction = $bus.get(:player_direction)
weapon.attack(direction)
elsif Gosu.button_down?(Gosu::MS_LEFT)
player_x, player_y = $bus.get(:player_position)
mouse_x, mouse_y = $bus.get(:mouse_position)
direction = Math.atan2(mouse_y - player_y, mouse_x - player_x)
weapon.attack(direction)
end
end
end