Compare commits

...

3 commits

Author SHA1 Message Date
7e24a44617 kill player offscreen 2025-11-11 23:20:52 -03:00
8be9c21ba2 despawn projectiles offscreen 2025-11-11 23:20:47 -03:00
6a251b3619 print amount of objects on debug 2025-11-11 23:16:26 -03:00
4 changed files with 16 additions and 2 deletions

View file

@ -33,7 +33,10 @@ function Room:draw()
camera:attach(0, 0, gw, gh)
self:canvasDraw()
camera:detach()
if DEBUG then love.graphics.print('DEBUG', 2, 2) end
if DEBUG then
love.graphics.print('objects: '..#self.area.game_objects,2,gh-16)
love.graphics.print('DEBUG', 2, 2)
end
love.graphics.setCanvas()
love.graphics.setColor(255, 255, 255, 255)

View file

@ -53,6 +53,12 @@ function Player:update(dt)
-- move collision area
self.collider:moveTo(self.x, self.y)
-- offscreen kill
if self.x < 0-self.w then self:kill() end
if self.y < 0-self.h then self:kill() end
if self.x > gw+self.w then self:kill() end
if self.y > gh+self.h then self:kill() end
if input:pressed('f11') then self:kill() end
end

View file

@ -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

View file

@ -41,7 +41,6 @@ end
function CircleRoom:canvasDraw()
CircleRoom.super.canvasDraw(self)
love.graphics.setColor(1, 1, 1)
love.graphics.print('objects: '..#self.area.game_objects,2,gh-16)
end
return CircleRoom