Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

im trying to find the x position of the mouse cursor

I’m making a game using python’s pygame module and am trying a new method where a weapon will rotate based on the mouse’s position, and I’m trying to find a point that would form a right angle between the center of the player’s cube and the mouse’s x position
this is the code:

point_a = (mouse.get_pos(), player_cube.centery)

if I wanted to find only the x position of ‘mouse.get_pos()’, how would I find it?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The pygame documentation states that the function returns the x and y values ​​you want.

pos = mouse.get_pos()
x = pos[0]
y = pos[1]

# or just one line
x, y = mouse.get_pos();
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading