aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/input.lua10
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()