bytepath/rooms/Stage.lua
2025-11-10 03:35:18 -03:00

34 lines
897 B
Lua

---@class Stage:Room
---@field timer Timer
local Stage = Room:extend()
function Stage:new()
Stage.super.new(self)
self.timer = Timer()
self.timer:every(2, function()
local latest_object = self.area:addGameObject('Circle', love.math.random(1, gw), love.math.random(1, gh))
latest_object.timer:after(love.math.random(2, 4), function() latest_object:kill() end)
end)
end
function Stage:update(dt)
Stage.super.update(self, dt)
if input:pressed('action') then
local latest_object = self.area:addGameObject('Circle', love.math.random(1, gw), love.math.random(1, gh), {radius = 15})
end
if input:pressed('right') then
for _, game_object in ipairs(self.area.game_objects) do
game_object:kill()
end
end
self.timer:update(dt)
end
function Stage:canvasDraw()
Stage.super.canvasDraw(self)
end
return Stage