From 318d6d8fbd989d8ae8abff28bbd0038c52289603 Mon Sep 17 00:00:00 2001 From: ne_mene Date: Fri, 3 Apr 2026 12:38:51 +0200 Subject: camera correct mouse --- src/input.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/input.lua') 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() -- cgit v1.3-2-g0d8e