Different delta time value

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Chinol
Prole
Posts: 5
Joined: Sun Aug 16, 2015 12:17 pm

Different delta time value

Post by Chinol »

Hi guys, its my first post on this forum so greetings for everyone! :D but... get to the point.

I did my first game in Love (just Pacman, nothing special). All is ok, but i have noticed that my game is a little bit laggy... So i decided to start it on my another computer (much more worse than my main computer) and... a value of delta time was lower (about 0.003) than value of delta time on ma main computer (about 0.015). Everyone knows what is going on ? :P
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Different delta time value

Post by ivan »

There is no way to guarantee a constant frame rate across computers.
Even on the same computer the frame rate could vary -
like for example if you run another process in addition to Love2D, then the delta value will increase.
There are several things you could do:
-multiply all velocity vectors by delta
-use accumulators and simulate the game by several "steps" per update
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Different delta time value

Post by Jasoco »

It doesn't matter. As long as the Delta Time is lower than 1/60 (0.01666666666667) then you'll still get 60FPS.

If you turn on VSync, then the Delta Time will consistently be around that anyway.

Just make sure you use dt for movement and animation.

For instance if you had an object and moved it at a speed of 100 pixels per second you'd just simply:

Code: Select all

object.x = object.x + 100 * dt
It could be pixels per second or tiles per second as long as it's units per second and you multiply it by dt.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Different delta time value

Post by T-Bone »

Assuming a constant frame rate, and not multiplying all speeds by dt is one of the most common beginner errors. Good thing you learnt about that now, rather than in a bigger project in the future!

If you need help implementing it in your game, please post it here and we can look at it :neko:
Chinol
Prole
Posts: 5
Joined: Sun Aug 16, 2015 12:17 pm

Re: Different delta time value

Post by Chinol »

T-Bone -> I always multiply speed by DT damn... ok but i have got one more problem with distribiuting my game on windows. I have done exactly what is on tutorial but it seems doesnt working... Love2d shows me messege "no game here" or something like that.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 2 guests