Slowing it down
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- SamPerson12345
- Prole
- Posts: 41
- Joined: Sat Aug 30, 2008 5:35 pm
Slowing it down
I'm working on a love game, but it goes way too fast. Does any one know how I can make it so that a section of code happens about once every half second? help would be greatly appreciated. :mrgreen:
-
- Citizen
- Posts: 94
- Joined: Thu Feb 21, 2008 1:11 am
Re: Slowing it down
Don't know what you mean but it sounds that you are not using delta time.
If you don't know what I mean than you should see Mike's screencast and read the documentation.
Otherwise you should provide some code example or better explanation.
If you don't know what I mean than you should see Mike's screencast and read the documentation.
Otherwise you should provide some code example or better explanation.
>>I love LÖVE.<<
- SamPerson12345
- Prole
- Posts: 41
- Joined: Sat Aug 30, 2008 5:35 pm
Re: Slowing it down
Wait, I got it now.
that will work right?
Code: Select all
function update(dt)
time = dt + time
if time > .5 then
function()
time = 0
end
end
Re: Slowing it down
I tend to use something very similar:
That way, even if update() is called at irregular intervals, function() will still be called the right number of times. It may not make much difference with 0.5s, but if you're trying to get something to happen 20 times a second then resetting time could cause it to be called an unpredictable number of times a second (if update() is called every 0.02 second, function() will be called about 17 times a second - once every 0.06s instead of once every 0.05s. If you keep the remainder it will be called 20 times a second, every 0.06s and 0.04s).
Code: Select all
function update(dt)
time = dt + time
if time > .5 then
function()
time = time - .5
end
end
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests