Timer
Posted: Tue Feb 25, 2014 10:57 pm
I am trying to make an object move randomly. I made a random number generator and want to set a timer to make the number generator generate a number every 1 or 2 seconds. I have it so when i push a key it will generate a number right now. Help?
Code: Select all
--elseif love.keyboard.isDown("i") then
--rand = math.random(1, 4)
end
if rand == 1 then
objects.box2.body:applyForce(500, 0 )
elseif rand == 2 then
objects.box2.body:applyForce(-500,0)
elseif rand == 3 then
objects.box2.body:applyForce(0, 500)
elseif rand == 4 then
objects.box2.body:applyForce(0, -500)
end