Fix For Laggy Delta Time

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Evine
Citizen
Posts: 72
Joined: Wed May 28, 2014 11:46 pm

Re: Fix For Laggy Delta Time

Post by Evine »

How about a more visual test.
The upper line is based on monitor vsync and the bottom line is based on dt.
Not much difference eh? But look closely and you'll see that one line has more jitter than the other.

Code: Select all

monitorDTposition = 0
loveDTposition = 0

monitorDT = 1 / select(3,love.window.getMode()).refreshrate

function love.update(dt)
	loveDT = dt

	monitorDTposition = monitorDTposition + monitorDT * 197.894563
	loveDTposition = loveDTposition + loveDT * 197.894563

	if monitorDTposition > 800 then -- Reset code
		monitorDTposition = -10
		loveDTposition = -10
	end
end

function love.draw()
	love.graphics.rectangle("fill",monitorDTposition,190,10,100)
	love.graphics.rectangle("fill",loveDTposition,310,10,100)
end

function love.timer.sleep() end -- Easy hack to kill the function

function love.keypressed(key)
	if key == "escape" then
		love.event.quit()
	end
end
Attachments
dtTest.love
(456 Bytes) Downloaded 127 times
Artal, A .PSD loader: https://github.com/EvineDev/Artal
User avatar
s-ol
Party member
Posts: 1077
Joined: Mon Sep 15, 2014 7:41 pm
Location: Cologne, Germany
Contact:

Re: Fix For Laggy Delta Time

Post by s-ol »

Evine wrote:How about a more visual test.
The upper line is based on monitor vsync and the bottom line is based on dt.
Not much difference eh? But look closely and you'll see that one line has more jitter than the other.

Code: Select all

monitorDTposition = 0
loveDTposition = 0

monitorDT = 1 / select(3,love.window.getMode()).refreshrate

function love.update(dt)
	loveDT = dt

	monitorDTposition = monitorDTposition + monitorDT * 197.894563
	loveDTposition = loveDTposition + loveDT * 197.894563

	if monitorDTposition > 800 then -- Reset code
		monitorDTposition = -10
		loveDTposition = -10
	end
end

function love.draw()
	love.graphics.rectangle("fill",monitorDTposition,190,10,100)
	love.graphics.rectangle("fill",loveDTposition,310,10,100)
end

function love.timer.sleep() end -- Easy hack to kill the function

function love.keypressed(key)
	if key == "escape" then
		love.event.quit()
	end
end
The question isn't whether there's jitter, the question is whether that jitter matters :P

s-ol.nu /blog  -  p.s-ol.be /st8.lua  -  g.s-ol.be /gtglg /curcur

Code: Select all

print( type(love) )
if false then
  baby:hurt(me)
end
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Fix For Laggy Delta Time

Post by zorg »

Evine wrote:How about a more visual test.
Both jitter the same amount the same time on my machine... so yeah :o:
Me and my stuff :3True 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.
User avatar
squidborne_destiny
Prole
Posts: 8
Joined: Wed May 28, 2014 8:32 pm

Re: Fix For Laggy Delta Time

Post by squidborne_destiny »

Ah, ok I realize now the error of my ways. Also, I realized that I didn't have vsynch enabled. Thanks for the help guys!
User avatar
squidborne_destiny
Prole
Posts: 8
Joined: Wed May 28, 2014 8:32 pm

Re: Fix For Laggy Delta Time

Post by squidborne_destiny »

Hey guys, thanks for the responses. I totally get why that doesn't work. Also I enabled Vsynch and the problem is totally gone. Problem gone so thanks. :nyu:
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest