diff options
| author | ne_mene <[email protected]> | 2026-03-14 11:54:19 +0100 |
|---|---|---|
| committer | ne_mene <[email protected]> | 2026-03-14 11:54:19 +0100 |
| commit | f13c4f845355d9902e5df62fbef19678cdbf7c40 (patch) | |
| tree | 5bd9ea0807f5bfaeb30ceeb311653ef787aa2558 /src/input.lua | |
| parent | 07ffb903dd30bc855692e36a37d3503d5a6cec75 (diff) | |
fixed mouse position
Diffstat (limited to 'src/input.lua')
| -rw-r--r-- | src/input.lua | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/input.lua b/src/input.lua index 207754e..5dacd81 100644 --- a/src/input.lua +++ b/src/input.lua @@ -12,7 +12,7 @@ end function input_direction(left, right, up, down) return bton(is_input_pressed(right)) - bton(is_input_pressed(left)), - bton(is_input_pressed(down)) - bton(is_input_pressed(up)) + bton(is_input_pressed(down)) - bton(is_input_pressed(up)) end function is_input_just_pressed(name) @@ -72,6 +72,7 @@ end function love.keypressed(key) keyEvents[key] = "Pressed" end + function love.keyreleased(key) keyEvents[key] = "Released" end @@ -100,9 +101,12 @@ function love.wheelmoved(...) end function get_mouse_pos() - -- TODO: Fix mouse position relative to games canvas local scrw, scrh = love.graphics.getDimensions() - return math.floor(lm.getX() / scrw * SCR_WIDTH), math.floor(lm.getY() / scrh * SCR_HEIGHT) + 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 end function input_step() |
