From 12752cf0d055d31438c244d6e025a3e0b11f1f0c Mon Sep 17 00:00:00 2001 From: iamcheeseman Date: Fri, 13 Mar 2026 20:33:28 -0400 Subject: Animations and variable jump height --- src/input.lua | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'src/input.lua') diff --git a/src/input.lua b/src/input.lua index b2951b2..cbc3f5b 100644 --- a/src/input.lua +++ b/src/input.lua @@ -25,10 +25,28 @@ function is_input_just_pressed(name) code = trig[2] if type == "mouse" then - if mouseEvents[code] ~= nil then return true end + if mouseEvents[code] == "Pressed" then return true end end if type == "key" then - if keyEvents[code] ~= nil then return true end + if keyEvents[code] == "Pressed" then return true end + end + end +end + +function is_input_just_released(name) + local inp = inputs[name] + local type + local code + + for _, trig in ipairs(inp) do + type = trig[1] + code = trig[2] + + if type == "mouse" then + if mouseEvents[code] == "Released" then return true end + end + if type == "key" then + if keyEvents[code] == "Released" then return true end end end end @@ -52,7 +70,10 @@ function is_input_pressed(name) end function love.keypressed(key) - keyEvents[key] = true + keyEvents[key] = "Pressed" +end +function love.keyreleased(key) + keyEvents[key] = "Released" end function love.mousepressed(_, _, btn) -- cgit v1.3-2-g0d8e