[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Mouse Speed



Charles Joseph Christie II wrote:
On Tuesday 01 May 2007 03:01:43 pm Rodney Brown wrote:
The more I read up on this, it seems what I should do is hide the real
mouse cursor and use a sprite instead.  Then I could maybe take the value
from pygame.mouse.get_rel() and cut the x/y values in half to slow down
movement of the sprite "cursor"?

[snip lots of stuff]

Wouldn't that cause sporadic jumping of the mouse?
Charles, when you reply to someone, can you try to remove as much of the irrelevant reply-stuff as possible?
It makes it hard to read through e-mails quickly otherwise.


As for the jumping of the mouse:
I don't see why the get_rel() would cause problems.
The docs say that the mouse will enter a virtual input mode, wherein relative mouse motion events won't be constrained to the edges of the screen,
so it sounds like this is a perfect solution.
Except, I'd use a multiplier instead of a divisor.
That way, later, you can have a configuration option slider
that goes from, for example, 0.5 to 1.5, and you multiply this value by all your relative mouse movements.
The only reason I suggest not using a divisor is because it's less clear what you mean if you have to describe the functionality to the user.
"if you set the slider on 1, the movements will be normal. on 2, they will be halved." etc.


Also, I'm not sure how get_rel() is reported, but I'd suggest maintaining the mouse cursor x and y values as floats, not integers.
Only because if you're callign get_rel() at a rate that results in only 1 or 0 change in the x-y values, and you multiply it by something less than 1,
and cast it as an integer, all your movement will be floored to 0.


HTH,
-Luke