aboutsummaryrefslogtreecommitdiff
path: root/src/input.lua
diff options
context:
space:
mode:
authoriamcheeseman <[email protected]>2026-03-13 20:33:28 -0400
committeriamcheeseman <[email protected]>2026-03-13 20:33:28 -0400
commit12752cf0d055d31438c244d6e025a3e0b11f1f0c (patch)
tree2952834517cd394d5553b8e3c60dfdc371fa9a55 /src/input.lua
parent973cc401d03a38cf889f122e74d92ab8cde053a1 (diff)
Animations and variable jump height
Diffstat (limited to 'src/input.lua')
-rw-r--r--src/input.lua27
1 files changed, 24 insertions, 3 deletions
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)