Refactor enemy system: enhance EnemyAI with attack cooldown, update Force class to handle damage, and improve EnemyHandler for enemy removal; add OccamsRazor weapon with attack mechanics.

This commit is contained in:
2026-03-30 19:39:43 +00:00
parent 60a89ed128
commit 0369d24338
9 changed files with 93 additions and 37 deletions
+29 -3
View File
@@ -1,9 +1,35 @@
class OccamsRazor
BASE_TIME = 0.2 # seconds per attack
def initialize
#
@time = 0
@active = false
@damage = 20
@range = 45 # how many pixels from player center to enemy center the attack hits, this is a melee weapon so it should be small
end
def attack(dt)
#
def attack
return if @active
@active = true
@time = BASE_TIME
# Check for enemies in range and deal damage
player_x, player_y = $bus.get(:player_position)
$bus.emit(:occams_razor_attack, player_x, player_y, @range, @damage)
end
def update(dt)
return unless @active
@time -= dt
if @time <= 0
@active = false
@time = 0
end
end
def draw
# Nothing for now, but player attack animation would go here
end
end