Pygame.mouse.set_pos() doesn't set the mouse position Pygame repl

I’m trying to lock the cursor position to the center of the screen in pygame, but when i go over to run it, it doesn’t lock, it does hide the cursor, but it doesn’t move it to the center. Which messes up the relative position.

pygame.mouse.set_visible(False)
pygame.event.set_grab(True)
pygame.mouse.set_pos((DISPLAYSURF.get_width() / 2,DISPLAYSURF.get_height() / 2))
mouserel = (pygame.mouse.get_rel())
mousex = mouserel[0]
mousey = mouserel[1]

I put this code in a loop, it would probably work in normal pygame, but it doesn’t on replit.

It is not possible to set the pos of a mouse over a Repl because the Repl is not running locally!
It is not moving your mouse, but would move the Repl VM’s mouse if anything.

This is because a Repl is streaming Outputs and sending them over the net!

Sorry, but I hope this helps!

2 Likes

It moves the repls mouse, but can’t they change the position of the mouse to the vm mouse when the output window gains focus?

1 Like

He’s talking about the VM’s mouse.

Yeah, unfortunately, you can’t move the actual mouse to the VM cursor position.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.