f54679de61
- Removed the State class as it was no longer needed. - Updated the MazeData class to improve output formatting. - Added new assets for HUD background and foreground. - Implemented Inventory class to manage crafting and item selection. - Created HUDLayer class to handle drawing the HUD and inventory interactions.
29 lines
585 B
Ruby
29 lines
585 B
Ruby
require_relative 'base'
|
|
|
|
class EnemyHandler
|
|
def initialize
|
|
@enemies = []
|
|
end
|
|
|
|
def update(dt)
|
|
spawn!
|
|
@enemies.each { |enemy| enemy.update(dt) }
|
|
end
|
|
|
|
def spawn!
|
|
# For now, just spawn a single enemy at a fixed location
|
|
#start_room_coords = $bus.get(:start_room_coords)
|
|
#if @enemies.empty?
|
|
# @enemies << Enemy.new((start_room_coords[0] * 2 + 1 + 4) * 60 + 30, (start_room_coords[1] * 2 + 1 + 4) * 60 + 30)
|
|
#end
|
|
end
|
|
|
|
def draw
|
|
@enemies.each(&:draw)
|
|
end
|
|
|
|
def collides?(rect)
|
|
@enemies.any? { |enemy| enemy.collides?(rect) }
|
|
end
|
|
end
|