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:
@@ -0,0 +1,16 @@
|
||||
require_relative 'base'
|
||||
|
||||
class ShrodingersMine < Trap
|
||||
def initialize(x, y)
|
||||
super(x, y)
|
||||
@sprite = Gosu::Image.new("assets/images/shrodingers_mine.png", retro: true)
|
||||
end
|
||||
|
||||
def stepped_on(entity)
|
||||
return false if entity == :character # shrodingers mine is safe for the player, so don't destroy it or cause a blast if the player steps on it
|
||||
if rand < 0.7 # 70% chance to be a landmine, 30% chance to be a dud
|
||||
$bus.emit(:blast, @x, @y, 50, 50, :safe) # blast radius of 50 and damage of 50, and always safe for the player
|
||||
end
|
||||
true # to destroy the trap
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user