Answer the question
In order to leave comments, you need to log in
How to fix the cursor to the center and receive the MOUSEMOTION event?
I'm making a 3D game in pygame using ray casting. It is necessary to make a rotation on the movement of the mouse. To do this, I catch the MOUSEMOTION event, add event.rel[0] to the player's rotation angle, and move the cursor back to the center.
for event in pygame.event.get():
if event.type == pygame.MOUSEMOTION:
pygame.mouse.set_pos(WIDTH // 2, HEIGHT // 2)
player.vx += event.rel[0] * SENSITIVITY
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question