Reputation: 118
mousepos = mouse.get_position()
if mousecontrol: # mouse control can be toggled
CAMERAANGLE[0] -= (mousepos[1] - pastcoords[1])*SENS # camera x angle
CAMERAANGLE[1] -= (mousepos[0] - pastcoords[0])*SENS # camera y angle
mouse.move(960,540) # resetting mouse to center of screen
pastcoords = mouse.get_position() # resetting mouse for next frame to calculate the distance the mouse travelled in a frame
^ this code is in a while loop and runs once every time the loop runs
This code works fine for computers at my school, however when I run this code on my home PC, the mouse control is extremely jittery and doesn't work.
My school computers run windows 10 with an Intel i5 10500T, and my home computer runs windows 10 with a 12400f and an RTX 3060
I added a timer to slow down the framerate, however this didn't fix the problem. Does anyone know what's going on here?
Upvotes: 0
Views: 51
Reputation: 118
The mouse would move a distance between mousepos = mouse.get_position()
and pastcoords = mouse.get_position()
, resulting in an inaccuracy in the mouse position - I fixed it by changing the code to this:
mousepos = mouse.get_position()
if mousecontrol: # mouse control can be toggled
CAMERAANGLE[0] -= (mousepos[1] - 540)*SENS # camera x angle
CAMERAANGLE[1] -= (mousepos[0] - 960)*SENS # camera y angle
mouse.move(960,540) # resetting mouse to center of screen
Upvotes: 0
Reputation: 11
It might be that the issue is with the mouse control implementation. The jitteriness might be caused by a difference in the processing power or mouse sensitivity between the two computers, or due to a difference in the mouse driver or hardware. It is also possible that there is a difference in the refresh rate or resolution between the two displays, which could be affecting the mouse position calculation. To solve this issue, you can try adjusting the mouse sensitivity, or try using a different mouse to see if the issue is with the hardware. You could also try running the code on a different display or resolution to see if that makes a difference.
Upvotes: 1