Implement enemy AI and handler; add placeable radar object; enhance maze functionality

This commit is contained in:
2026-03-25 22:02:50 +00:00
parent 84004a9f67
commit 83d250f1e9
13 changed files with 478 additions and 24 deletions
+28
View File
@@ -0,0 +1,28 @@
require_relative 'base'
class EnemyHandler
def initialize
@enemies = []
end
def update
spawn!
@enemies.each(&:update)
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] + 4) * 60 + 30, (start_room_coords[1] + 4) * 60 + 30)
end
end
def draw
@enemies.each(&:draw)
end
def collides?(rect)
@enemies.any? { |enemy| enemy.collides?(rect) }
end
end