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