Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8573859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:20:47+00:00 2026-06-11T19:20:47+00:00

I am not writing a game but a scientific renderer using Pygame. I’d like

  • 0

I am not writing a game but a scientific renderer using Pygame. I’d like the controls to work just like in a first-person shooter, so that a user can navigate using a familiar set of controls.

I have tried to write the code to have the same properties as the ‘look’ feature in e.g. Skyrim or Half-Life but the mouse doesn’t move the cursor – it lets you look around and around, in infinite circles. Clicking should have no effect.

The first attempt for the controls:

(code inside a game loop)

delta_y, delta_x = pygame.mouse.get_rel()
rotation_direction.x = float(delta_x)
rotation_direction.y = float(delta_y)

(don’t ask me why, but y and x need to be reversed like this to get the expected look directions; must be something to do with the camera transform implementation, which isn’t mine.)

This, however, leads to a cursor sitting on top of the window, and when the cursor gets to the edge of the screen the window stops rotating; i.e. the code is reporting the actual position on the screen.

I tried to ‘reset’ the mouse position every game loop (and, incidentally, hide the mouse):

pygame.mouse.set_pos([150, 150])
pygame.mouse.set_visible(False)

But this generates a symmetrical ‘move back to start’ delta in the next loop, meaning that you couldn’t ‘look’ anywhere.

To summarize, I want to:

  • detect actual mouse motion reported from the device
  • not move/show any OS cursor
  • not clip at the ‘edge of a screen’

What is the best way to do this, using Pygame or other Python hacks?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:20:48+00:00Added an answer on June 11, 2026 at 7:20 pm

    http://www.pygame.org/docs/ref/mouse.html :

    If the mouse cursor is hidden, and input is grabbed to the current display the mouse will enter a virtual input mode, where the relative movements of the mouse will never be stopped by the borders of the screen. See the functions pygame.mouse.set_visible – hide or show the mouse cursor and pygame.event.set_grab (docs) – control the sharing of input devices with other applications to get this configured.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a 3d game that is using GL10, but I'd like the
I feel like I am not writing this correctly and this is my first
I'm writing a memory game, like concentration . Using jQuery, how do I cover
I'm currently using libgdx for game I'm writing, and I just continued writing this
I'm writing a game using android ndk. I'm using picking to select objects in
I'm writing a Connect4 game with an AI opponent using adversarial search techniques and
I'm writing a Mahjong Game in C# (the Chinese traditional game, not the solitaire
I'm writing a game in Python with the Pygame2 multimedia library, but I'm more
I'm writing a game in html5 and using wordpress for the rest of the
I'm writing an isometric game, but unfortunately I've got stuck writing with the algorithm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.