I've got a pygame project, in which the user needs to be able to click buttons on the screen. I have done this by getting the mouse position using this line:
x, y = pygame.mouse.get_pos()
and then checking if the mouse is touching the surface with this line:
if self.rect.collidepoint(x, y):
However, I have recently allowed my pygame window to be resizable. I made the buttons always stay centred in the middle of the window when I resize it. However, now the mouse position script seems to be offset. The buttons operate when I click where they used to be before the window was resized, not where the buttons have been moved since.
Any help on how to solve this problem would be greatly appreciated!