Mouse delay?

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
kirbunkle
Prole
Posts: 9
Joined: Tue Jul 17, 2012 8:16 am

Mouse delay?

Post by kirbunkle »

I've noticed that there is a small delay between when the actual mouse moves and when I draw my custom mouse. I draw it as just an image using the mouse.getPosition() coordinates to find out where to put it, but it always seems to be just a split second behind. It is noticeable.

It seems to be an issue with how love gets the mouse position, presumably only once every iteration of the game loop. But by the time it is displayed on the screen, the mouse has already moved to a different position.

I was wondering if there was a solution or some kind of work-around. Any help is greatly appreciated.
User avatar
juno
Citizen
Posts: 85
Joined: Thu May 10, 2012 4:32 pm
Location: London

Re: Mouse delay?

Post by juno »

Maybe take the mouse positioning code out of the game loop and have it at the start of the update function?
wat ya mean she's in another castle!?
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Mouse delay?

Post by Santos »

You may or may not want to turn vsync off using love.graphics.setMode or conf.lua (discussed further here: viewtopic.php?f=4&t=9098)
kirbunkle
Prole
Posts: 9
Joined: Tue Jul 17, 2012 8:16 am

Re: Mouse delay?

Post by kirbunkle »

Santos wrote:You may or may not want to turn vsync off using love.graphics.setMode or conf.lua (discussed further here: viewtopic.php?f=4&t=9098)
Amazing, it works. The delay is gone.

But I noticed that the fps shot up to like 500.

Are there any reasons why I would want to leave vsync on? Does a game require more CPU with it off? Should I try to reduce the update rate (have a check and update only 60 times a second) to compensate for the high frame rate? Lol, lots of questions, sorry. :P

Thanks for the help. :D
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Re: Mouse delay?

Post by Santos »

I'm glad I could help! :D

It's there to prevent screen tearing.

I have no idea about CPU usage sorry. :D

Using dt properly inside love.update means the framerate won't affect the speed of things in game.
kirbunkle
Prole
Posts: 9
Joined: Tue Jul 17, 2012 8:16 am

Re: Mouse delay?

Post by kirbunkle »

Santos wrote:I'm glad I could help! :D

It's there to prevent screen tearing.

I have no idea about CPU usage sorry. :D

Using dt properly inside love.update means the framerate won't affect the speed of things in game.
Maybe I'll play with it to see if there's any negative effects. Now that I know what I can do about it, I might be able to come up with some work-around if I do see some problems.

Thanks!
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Mouse delay?

Post by Nixola »

If the video drivers are good, playing with vsync on is faster than playing without it (it depends on the framerate difference). If the video drivers are bad, it's slow in both cases.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
josefnpat
Inner party member
Posts: 955
Joined: Wed Oct 05, 2011 1:36 am
Location: your basement
Contact:

Re: Mouse delay?

Post by josefnpat »

The next time you have problems, please check the forums.

Here is another thread on the subject: viewtopic.php?f=4&t=2780
Missing Sentinel Software | Twitter

FORCIBLY IGNORED.
<leafo> when in doubt delete all of your code
<bartbes> git rm -r *
<bartbes> git commit -m "Fixed all bugs"
<bartbes> git push
User avatar
dreadkillz
Party member
Posts: 223
Joined: Sun Mar 04, 2012 2:04 pm
Location: USA

Re: Mouse delay?

Post by dreadkillz »

This is a well known issue in video games, especially if you've played counter strike or any shooters a lot in the past. Vsync is just nasty cause it's artifically delaying frames to sync with your refresh rate, so it looks like your video is lagging. (at least that's how I recall researching this many many years ago).
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Mouse delay?

Post by bartbes »

dreadkillz wrote:Vsync is just nasty cause it's artifically delaying frames to sync with your refresh rate
It's awesome! It prevents screen tear, it prevents me from having more fps than I'll ever need (because my monitor wouldn't be able to display it), and it's nice on my cpu too (YMMV). That said, for really responsive controls you'll need to have it off, in general though, it's good enough with it on.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 20 guests