diff --git a/sonic-radiance.love/scenes/overworld/actors/player/actions.lua b/sonic-radiance.love/scenes/overworld/actors/player/actions.lua index 4df0b41..6d98c01 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player/actions.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player/actions.lua @@ -4,7 +4,7 @@ local BASE_SPEED = 120 local JMP_STRENGHT = 2.5 function PlayerActions:initActions() - self.isJumping = false + self.currentAction = "idle" end function PlayerActions:actionMove() @@ -30,20 +30,20 @@ function PlayerActions:actionJump() if self.keys["B"].isPressed then if (self.onGround) then self:goUpward(JMP_STRENGHT) - self.isJumping = true self.assets.sfx["jump"]:play() + self.currentAction = "jump" end end end function PlayerActions:actionSwitch() - if self.keys["select"].isPressed and self.onGround then + if self.keys["select"].isPressed and (self.currentAction == "idle") then self:switchActiveCharacter() end end function PlayerActions:endJump() - self.isJumping = false + self.currentAction = "idle" end return PlayerActions diff --git a/sonic-radiance.love/scenes/overworld/actors/player/charset.lua b/sonic-radiance.love/scenes/overworld/actors/player/charset.lua index 9ae358d..9703a77 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player/charset.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player/charset.lua @@ -1,19 +1,32 @@ local PlayerCharset = Object:extend() +local ACTIONS_LARGEANIM = {"jump"} +local ACTIONS_ISFAST = {"jump"} + function PlayerCharset:initPlayerCharset() self:updateCurrentCharset() end function PlayerCharset:updateCurrentCharset() - if (not self.isJumping) then - self:setCharset(self.active.data.charset, self.active.data.charId) - self.largeAnim = false - self.isFast = false - else - self:setCharset(self.active.data.charset .. "-jump", self.active.data.charId) - self.largeAnim = true - self.isFast = true - end - end + self:setCharset(self:getCharset(), self.active.data.charId) + self.isFast = self:getIsFast() + self.largeAnim = self:getLargeAnim() +end - return PlayerCharset \ No newline at end of file +function PlayerCharset:getCharset() + local charset = self.active.data.charset + if (self.currentAction == "jump") then + charset = charset .. "-jump" + end + return charset +end + +function PlayerCharset:getLargeAnim() + return utils.table.contain(ACTIONS_ISFAST, self.currentAction) +end + +function PlayerCharset:getIsFast() + return utils.table.contain(ACTIONS_LARGEANIM, self.currentAction) +end + +return PlayerCharset