diff --git a/imperium-porcorum.love/scenes/levels/entities/debris.lua b/imperium-porcorum.love/scenes/levels/entities/debris.lua index 1bdfc48..183deed 100644 --- a/imperium-porcorum.love/scenes/levels/entities/debris.lua +++ b/imperium-porcorum.love/scenes/levels/entities/debris.lua @@ -4,9 +4,10 @@ local Debris = Entity:extend() function Debris:new(world, x, y, speed, dir, timelimit) Debris.super.new(self, world, "debris", x - 4, y - 4, 8, 8) - self.life = 0; - self.timer = 0 - self.timelimit = timelimit or 2 + local timelimit = timelimit or 2 + + self:addTimer("timelimit", timelimit) + self:setMotionDirection(dir, speed) self:setGravityFlag(true) self:setBounceFactor(0.5) @@ -31,9 +32,10 @@ function Debris:updateEnd(dt) if (isInsideView == false) then self:destroy() end +end - self.timer = self.timer + dt - if (self.timer >= self.timelimit) then +function Debris:timerResponse(timer) + if (timer == "timelimit") then self:destroy() end end