In most languages/engines/frameworks, I could just write the movement code like this:
x = x + (speed * dt)
And it would work fine. But in Love2D, the dt changes nothing. If it's at 60FPS, it will move at a certain speed. If it's 20FPS, it will be much slower. What can I do?
Make speed constant no matter the FPS
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Make speed constant no matter the FPS
You could show us some actual code, or even better upload a working .love file that showcases your issue; the snippet itself looks fine.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Make speed constant no matter the FPS
if you put dt as a parameter into the love.update callback (or whatever function you put that code in, while passing love.update's dt into it) it should work. As Nixola said, post a bit more code.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Make speed constant no matter the FPS
In my experience, dt has always worked as it should. As was said, provide an example that gives us the result you're seeing and we'll tell you if anything is wrong.
Also maybe your system specs.
Also maybe your system specs.
Re: Make speed constant no matter the FPS
My guess would be you're using the dt of the update function inside the draw.
- Jasoco
- Inner party member
- Posts: 3726
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Make speed constant no matter the FPS
As has been mentioned, as long as you pass dt into every function you place in update that has anything to do with movement or speed or whatever, it should work fine. And don't try to use it in love.draw as it won't work, but you can make it work if you absolutely have to by either calling love.timer.getDelta() manually or rewriting love.run to pass dt into love.draw as well and treating it the same. If you have to.
Who is online
Users browsing this forum: Bing [Bot] and 5 guests