Reputation: 3
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
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
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