Implement traps system: add Trap, Landmine, and EventHorizon classes with collision detection and interaction logic; integrate trap handling in the game scene and enemy AI.

This commit is contained in:
2026-04-02 22:46:24 +01:00
parent db7c2aa7a2
commit 7c35419026
20 changed files with 294 additions and 13 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ class WeaponHandler
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)
mouse_x, mouse_y = $bus.get(:mouse_pos)
direction = Math.atan2(mouse_y - player_y, mouse_x - player_x)
weapon.attack(direction)
end
+6 -7
View File
@@ -1,17 +1,16 @@
class LorentzField
BASE_TIME = 25 # Base time for the field to be active in seconds
def initialize(bus)
@bus = bus
def initialize
@time = 0
@active = false
@font = Gosu::Font.new(24, name: "assets/fonts/tn.ttf")
@bus.on(:lorentz_field?) do
$bus.on(:lorentz_field?) do
next @active
end
@bus.on(:lorentz_field) do
$bus.on(:lorentz_field) do
if @active
t = @time
remaining = BASE_TIME - t
@@ -34,10 +33,10 @@ class LorentzField
def attack(_direction)
return if @active
@bus.emit(:consume, :lorentz_field, 1)
$bus.emit(:consume, :lorentz_field, 1)
@active = true
@time = 0
@bus.emit(:lorentz_field!, true)
$bus.emit(:lorentz_field!, true)
end
def update(dt)
@@ -47,7 +46,7 @@ class LorentzField
if @time >= BASE_TIME
@time = 0
@active = false
@bus.emit(:lorentz_field!, false)
$bus.emit(:lorentz_field!, false)
end
end