Bug about "set_mouse_pos" and "get_mouse_pos"?

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
Emanon1136
Newbie
Posts: 4
Joined: Thu Jun 09, 2016 12:05 am
Contact:

Bug about "set_mouse_pos" and "get_mouse_pos"?

#1 Post 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!
Last edited by Emanon1136 on Wed Nov 01, 2023 11:34 pm, edited 1 time in total.

jeffster
Veteran
Posts: 409
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

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

#2 Post by jeffster »

I got 100, 100.

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

🤔

Emanon1136
Newbie
Posts: 4
Joined: Thu Jun 09, 2016 12:05 am
Contact:

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

#3 Post 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!

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot]