Issues with dt and multiple windows
Posted: Fri Aug 08, 2014 4:01 pm
I'm trying to make my charecter jump with the following code:
where meow.y is the Y value of the sprite and meow.gravity is initially 50.
However, if I have multiple windows or something going on in the background, my character jumps a LOT higher that its supposed to. I read the wiki and it seems like dt is just the amount of time from the previous frame update, so how should I program this jump so that it lasts for the same amount of time on all machines?
Code: Select all
function love.update(dt)
[...]
if love.keyboard.isDown("w") then
dTotal = dTotal + dt
meow.y = meow.y - (meow.gravity *25* dt)
if (meow.gravity > 2.1) then meow.gravity = meow.gravity - 0.8 end
if (meow.gravity < 2) then meow.gravity = 1 end
end
[...]
end
However, if I have multiple windows or something going on in the background, my character jumps a LOT higher that its supposed to. I read the wiki and it seems like dt is just the amount of time from the previous frame update, so how should I program this jump so that it lasts for the same amount of time on all machines?