Laggy keyboard movement

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.
Post Reply
User avatar
mcjohnalds45
Prole
Posts: 18
Joined: Sat Jun 02, 2012 12:08 pm

Laggy keyboard movement

Post by mcjohnalds45 »

When making a graphic move across the screen with frame rate independent movement with

Code: Select all

if love.keyboard.isDown("w") then
	y = y - 200 * dt --dt is the delta time
end
if love.keyboard.isDown("a") then
	x = x - 200 * dt
end
if love.keyboard.isDown("s") then
	y = y + 200 * dt
end
if love.keyboard.isDown("d") then
	x = x + 200 * dt
end
The movement of the graphic appears to have inconsistent lag, but when moving a graphic across the screen with the typical

Code: Select all

if love.keyboard.isDown("w") then
	y = y - 5
end
if love.keyboard.isDown("a") then
	x = x - 5
end
if love.keyboard.isDown("s") then
	y = y + 5
end
if love.keyboard.isDown("d") then
	x = x + 5
end
The movement is totally smooth, is it something to do with the delta-time being inaccurate on 32 bit machines or something?

Excluding that minor hiccup, the love framework is looking really awesome, I can't wait to make my ninjas vs civil war soldiers game!
Attachments
test.love
W,A,S,D for frame independent movement, arrow keys for frame dependent movement
(342 Bytes) Downloaded 91 times
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Laggy keyboard movement

Post by bartbes »

It's probably related to drawing on non-integer coordinates, what happens if you round the coordinates before drawing?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Laggy keyboard movement

Post by Robin »

To be honest, I don't see any difference.
Help us help you: attach a .love.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Laggy keyboard movement

Post by Nixola »

I see a more laggy movement when moving without dt...
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
mcjohnalds45
Prole
Posts: 18
Joined: Sat Jun 02, 2012 12:08 pm

Re: Laggy keyboard movement

Post by mcjohnalds45 »

Thanks for the suggestion bartbets, but it didn't work, I'm assuming you meant putting

Code: Select all

x = math.floor(x)
y = math.floor(y)
at the end of the update function, must be something wrong with the love framework, the lag is very noticeable on my crappy windows xp os, oh well I'll just stick with the good ol' simple way.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Laggy keyboard movement

Post by bartbes »

That's not what I meant, because that will make movement incorrect, you need to round (down) what you pass to love.graphics.draw, not what you manipulate.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Semrush [Bot] and 1 guest