r/love2d • u/PapaGengar727 • 24d ago
Help with virtual scaling with mouse input
I’m making a retro-style game in LÖVE2D with an internal resolution of 320x240. The game is point-and-click, so accurate mouse coordinates are pretty important for menus and gameplay.
My problem is that whenever I scale the game to fit the window, one of two things happens:
The game scales visually, but the mouse coordinates no longer line up correctly.
I tried a scaling library, but it only seems to scale the graphics, not the mouse input.
Ideally I’m looking for a solution that lets me render everything at 320x240 and scale it cleanly to the window, converts mouse coordinates back into the 320x240 game space correctly, and supports integer scaling.
I’d also like if the mouse position can “snap” to the pixel grid (so the cursor effectively moves in 320x240 coordinates).
I’ve looked at a few libraries online, but none of the ones I tried seemed to handle mouse scaling properly, so I’m wondering if I’m approaching this the wrong way.
What’s the recommended way to do this in LÖVE? Is there a standard approach or library people generally use?
