feat: add flight

This commit is contained in:
Kazhnuz 2021-04-10 18:28:52 +02:00
parent 8f27270c39
commit 34b409f423
7 changed files with 35 additions and 6 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View file

@ -30,6 +30,7 @@ function Parent:initCharset()
self.isTurning = false
self.isFast = false
self.largeAnim = false
self.alwaysWalk = false
end
function Parent:setCharset(charset, charId, cantWalk)
@ -50,7 +51,7 @@ function Parent:drawCharset(charset, charId)
self.charsetManager:drawLargeAnim(self.charset, self.charId, self.charDir, x, y - z, self.isFast)
else
if (not self.isTurning) then
if (self:isMoving() and (not self.cantWalk)) then
if ((self:isMoving() and (not self.cantWalk)) or self.alwaysWalk) then
self.charsetManager:drawMoving(self.charset, self.charId, self.charDir, x, y - z, self.isFast)
else
self.charsetManager:drawStanding(self.charset, self.charId, self.charDir, x, y - z, self.isFast)

View file

@ -43,8 +43,25 @@ function PlayerActions:actionJump()
self:goUpward(JMP_STRENGHT)
self.assets.sfx["jump"]:play()
self.currentAction = "jump"
elseif (self.currentAction == "jump" and self:canDoAction("fly")) then
self.currentAction = "fly"
self.grav = 0
self.zsp = 0
self.tweens:newTimer(0.75, "endFly")
self.assets.sfx["fly"]:play()
end
end
if self.keys["B"].isReleased then
self:endFly()
end
end
function PlayerActions:endFly()
if (self.currentAction == "fly") then
self:goUpward(0)
self.currentAction = "idle"
end
end
function PlayerActions:actionSwitch()

View file

@ -1,7 +1,8 @@
local PlayerCharset = Object:extend()
local ACTIONS_LARGEANIM = {"jump"}
local ACTIONS_ISFAST = {"jump"}
local ACTIONS_ISFAST = {"jump", "fly"}
local ACTIONS_ALWAYSWALK = {"fly"}
function PlayerCharset:initPlayerCharset()
self:updateCurrentCharset()
@ -11,22 +12,29 @@ function PlayerCharset:updateCurrentCharset()
self:setCharset(self:getCharset(), self.active.data.charId)
self.isFast = self:getIsFast()
self.largeAnim = self:getLargeAnim()
self.alwaysWalk = self:getAlwaysWalk()
end
function PlayerCharset:getCharset()
local charset = self.active.data.charset
if (self.currentAction == "jump") then
charset = charset .. "-jump"
elseif (self.currentAction == "fly") then
charset = charset .. "-flight"
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
function PlayerCharset:getIsFast()
return utils.table.contain(ACTIONS_ISFAST, self.currentAction)
end
function PlayerCharset:getAlwaysWalk()
return utils.table.contain(ACTIONS_ALWAYSWALK, self.currentAction)
end
return PlayerCharset

View file

@ -95,6 +95,8 @@ end
function Player:timerResponse(response)
if (response == "changeCharacter") then
self:endCharacterSwitchAnimation()
elseif (response == "endFly") then
self:endFly()
end
end

View file

@ -45,6 +45,7 @@ return {
{"hit", "assets/sfx/hit.wav"},
{"hitconnect", "assets/sfx/hitconnect.wav"},
{"jump", "assets/sfx/jump.wav"},
{"fly", "assets/sfx/flight.wav"},
{"woosh", "assets/sfx/woosh.wav"},
{"spincharge", "assets/sfx/spincharge.wav"},
{"spinrelease", "assets/sfx/spinrelease.wav"},