_G.love = require("love")
function love.load()
listofRectangles = {}
_G.game = {
countdowntimer = 0
}
gamechart()
end
function love.update(dt)
for i,v in ipairs(listofRectangles) do
v.y = v.y + v.speed * dt
end
end
function love.draw()
for i,v in ipairs(listofRectangles) do
love.graphics.rectangle("line", v.x, v.y, v.width, v.height)
end
end
function createRectangle()
rectangle = {}
rectangle.width = 50
rectangle.height= 50
rectangle.x = 300
rectangle.y = 200
rectangle.speed = 150
return rectangle
end
function gamechart()
-- heres where im trying to make it wait to spawn
table.insert(listofRectangles, createRectangle())
end
local function newTimer(seconds, callback)
return {
duration = seconds,
callback = callback,
elapsedTime = 0,
active = true
}
end
local function updateTimer(timer, dt)
if timer.active then
timer.elapsedTime = timer.elapsedTime + dt
if timer.elapsedTime >= timer.duration then
timer.active = false
timer.callback()
return true -- true means: timer must be deleted
end
end
end