From 34a56fedcf2cf1d39245e018a053e3f29097ad72 Mon Sep 17 00:00:00 2001 From: Raimon Zamora Date: Thu, 19 Jun 2025 12:44:51 +0200 Subject: [PATCH] - [FIX] mouse.pos() donava coordenades reals de finestra, en compte de tindre en compte el zoom. --- data/main.lua | 4 ++++ mini.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/data/main.lua b/data/main.lua index 5d59710..dd0ded3 100644 --- a/data/main.lua +++ b/data/main.lua @@ -29,4 +29,8 @@ function mini.update() if key.press(key.N3) then shader.disable() end + + local mx, my = mouse.pos() + draw.rectf(mx, my, 4, 4, 8) + draw.text(mx .. " " .. my, 1, 8, 8) end diff --git a/mini.cpp b/mini.cpp index 7d23fa3..56d7679 100644 --- a/mini.cpp +++ b/mini.cpp @@ -505,8 +505,8 @@ int main(int argc,char*argv[]){ mouse_buttons = SDL_GetMouseState(&real_mouse_x, &real_mouse_y); float mx, my; SDL_RenderCoordinatesFromWindow(mini_ren, real_mouse_x, real_mouse_y, &mx, &my); - mouse_x = int(mx); - mouse_y = int(my); + mouse_x = int(mx/screen_zoom); + mouse_y = int(my/screen_zoom); //mouse_x /= screen_zoom; mouse_y /= screen_zoom; if (SDL_GetTicks()-dt>13) {