-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcrouching.lua
More file actions
31 lines (24 loc) · 756 Bytes
/
crouching.lua
File metadata and controls
31 lines (24 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
local state = require "state"
local crouching = {}
setmetatable(crouching,crouching)
function crouching:__call(c1,c2,buttons,combinations,fpcombinations,patternStates)
local nt = state(c1,c2,buttons,combinations,fpcombinations,patternStates)
setmetatable(nt,{__index = crouching})
return nt
end
crouching.__index = state
function crouching:checkInputs()
if not state.checkInputs(self) then
--return to standing if no down is held
if not(self.c1.handler:isHeld('ld') or self.c1.handler:isHeld('d') or self.c1.handler:isHeld('rd')) then
self.c1:setState(self.c1.standing)
end
end
end
function crouching:update()
if(self.c1.x < self.c2.x ~= self.c1.lookingRight) then
self.c1:flip(226)
end
self:checkInputs()
end
return crouching