diff --git a/obj/game/Projectile.lua b/obj/game/Projectile.lua index 910a87b..ac2b4b3 100644 --- a/obj/game/Projectile.lua +++ b/obj/game/Projectile.lua @@ -30,6 +30,12 @@ function Projectile:update(dt) -- move collision area self.collider:moveTo(self.x, self.y) + + -- offscreen despawn + if self.x < 0 then self:kill() end + if self.y < 0 then self:kill() end + if self.x > gw then self:kill() end + if self.y > gh then self:kill() end end ---Draws Projectile