I want to obtain coordinates of mouse position at the time when the mouse button is pressed. I'm using the following code to try to achieve that:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
elif event.type == pygame.MOUSEBUTTONDOWN:
mouse_pos = event.pos
My problem is when I move the mouse just after clicking, event.pos gives me the new cursor position instead of the coordinates of where I actually clicked. How do I set mouse_pos to the actual coordinates of the click?
mouse_pos = event.pos,mouse_poswill contain the actual coordinates of the click. Maybe you overwrite it elsewhere in your code? - sloth