Enhance enemy AI and weapon mechanics: add knockback effect based on player position in Enemy class; improve attack direction handling and animation in OccamsRazor class.

Basically the finishing touches.
This commit is contained in:
2026-04-03 14:59:28 +01:00
parent bf1171a775
commit 35cddfc53c
3 changed files with 40 additions and 5 deletions
+6
View File
@@ -58,6 +58,12 @@ class Enemy
end
def take_damage(amount)
# knockback a bit based on player position
player_x, player_y = $bus.get(:player_position) || [0, 0]
angle = Math.atan2(@y - player_y, @x - player_x)
knockback_distance = 10
@x += Math.cos(angle) * knockback_distance
@y += Math.sin(angle) * knockback_distance
@health -= amount
if @health <= 0
$bus.emit(:enemy_died, self)