aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorne_mene <[email protected]>2026-04-03 12:38:51 +0200
committerne_mene <[email protected]>2026-04-03 12:38:51 +0200
commit318d6d8fbd989d8ae8abff28bbd0038c52289603 (patch)
treea459bc7cc1723bb39c282c45d8ed727c9c3b5441 /src
parent28bfd0fb251fab685046b8951b1c7aa9c59ef020 (diff)
camera correct mouse
Diffstat (limited to 'src')
-rw-r--r--src/input.lua17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/input.lua b/src/input.lua
index 5dacd81..7c625ed 100644
--- a/src/input.lua
+++ b/src/input.lua
@@ -101,12 +101,25 @@ function love.wheelmoved(...)
end
function get_mouse_pos()
+ local cam = get_active_camera()
local scrw, scrh = love.graphics.getDimensions()
+
local offset_x = (scrw - SCR_WIDTH * WindowScale) / 2
local offset_y = (scrh - SCR_HEIGHT * WindowScale) / 2
- return (lm.getX() - offset_x) / WindowScale,
- (lm.getY() - offset_y) / WindowScale
+ local mx = (lm.getX() - offset_x) / WindowScale
+ local my = (lm.getY() - offset_y) / WindowScale
+
+ mx = mx - SCR_WIDTH / 2
+ my = my - SCR_HEIGHT / 2
+
+ mx = mx / cam.zoom
+ my = my / cam.zoom
+
+ mx = mx + cam.realx
+ my = my + cam.realy
+
+ return mx, my
end
function input_step()