34 lines
874 B
Lua
34 lines
874 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, 800), love.math.random(1, 600))
|
|
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, 800), love.math.random(1, 600))
|
|
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:draw()
|
|
Stage.super.draw(self)
|
|
end
|
|
|
|
return Stage
|