ryiki pierson
ryiki pierson

Reputation: 3

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?

Upvotes: 0

Views: 224

Answers (2)

Y.C.
Y.C.

Reputation: 201

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();

Upvotes: 1

Pink Z
Pink Z

Reputation: 24

mouse.get_pos()[0] - mouse.get_pos() returns a tuple (list) alternatively you could put pos = mouse.get_pos() x = pos[0]

Upvotes: 0

Related Questions