Page 1 of 1

Bug about "set_mouse_pos" and "get_mouse_pos"?

Posted: Wed Jun 21, 2023 9:30 am
by Emanon1136
This phenomenon seems disappeared in Renpy 8.1.3, now I can get the same result via "set_mouse_pos" and "get_mouse_pos" at the same time.
I don't know if it is a bug repaired or it's my computer's own problem...
####################################################################################
I use "renpy.set_mouse_pos(x,y)" and then use "(nx,ny) = renpy.get_mouse_pos()" immediately, expecting "nx = x" and "ny = y". However, I get "nx = x-1" and "ny = y-1". I test for different (x,y) and it seems "nx = x" only happens when "x = 960" (my screen width is 1920), under other situations it's always "nx = x-1" and "ny = y-1".
I don't know if it's a bug or it's my own problem?
Sorry my English is poor. Code is like below:

Code: Select all

label start:
	pause 5.0
	$ renpy.set_mouse_pos(100,100)
	"Use space, don't move your mouse."
	$ (nx,ny) = renpy.get_mouse_pos()
	"(nx,ny) is ([nx],[ny])!"
Looking forward to your answer! Thank you!

Re: Bug about "set_mouse_pos" and "get_mouse_pos"?

Posted: Thu Jun 22, 2023 6:29 pm
by jeffster
I got 100, 100.

But then I tried 123, 123 and got 122, 123.

🤔

Re: Bug about "set_mouse_pos" and "get_mouse_pos"?

Posted: Sat Jun 24, 2023 10:57 pm
by Emanon1136
Oh, that's what I worried about... If different computers get different results, my code might be wrong in other devices.
In fact, I try to make an effect like fps game, the background will move with your mouse, which needs to get your mouse position. But it went wrong at the edge when I use the set_mouse_pos() function after get mouse position immediately because I need to limit the mouse position at the max and min values so that my screen will not go out of the background. It seems I have to plus one to the position before use set_mouse_pos() in my device. Maybe I shouldn't use these functions like this?
Whatever, thank you for your help!