local PlayerActions = Object:extend() local BASE_SPEED = 120 local JMP_STRENGHT = 2.5 function PlayerActions:initActions() self.currentAction = "idle" end function PlayerActions:actionMove() if self.keys["up"].isDown then self.ysp = -BASE_SPEED self.charDir = "up" end if self.keys["down"].isDown then self.ysp = BASE_SPEED self.charDir = "down" end if self.keys["left"].isDown then self.xsp = -BASE_SPEED self.charDir = "left" end if self.keys["right"].isDown then self.xsp = BASE_SPEED self.charDir = "right" end end function PlayerActions:actionJump() if self.keys["B"].isPressed then if (self.onGround) then self:goUpward(JMP_STRENGHT) self.assets.sfx["jump"]:play() self.currentAction = "jump" end end end function PlayerActions:actionSwitch() if self.keys["select"].isPressed and (self.currentAction == "idle") then self:switchActiveCharacter() end end function PlayerActions:endJump() self.currentAction = "idle" end return PlayerActions