Search code examples
pythonpython-3.xpygamepygame-surfacepygame2

In pygame how can i create a data struct that keeps track of resizing events and the coordinates of objects?


I'm looking to keep my mouse events in sync with my objects after resizing the screen.
I'm told I need to create a data structure to keep track of:

  • Resizing events

  • New coordinates to match the resize

How can I accomplish this using simple algebraic equations and integrate it into a resize event for accurate updating?


Solution

  • Do it the other way around create a virtual game map, scale to the size of the window when drawing the scene and scale to the size of the virtual map when receiving an event.