how do i make a countdown timer?
Posted: Mon Jul 08, 2024 6:14 pm
im trying to make a timer to wait for my objects to spawn
plz help
heres my code:
plz help
heres my code:
Code: Select all
_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