From 4598b25e05dc10bde51f432b8912b3f2b626c96b Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 28 May 2022 11:55:21 +0200 Subject: [PATCH] feat: add hit combo --- .../world/actors/fighters/player/controls.lua | 21 ++++++++++++------- .../world/actors/fighters/player/init.lua | 4 ---- .../world/actors/fighters/states/hit1.lua | 20 ++++++++++++++++++ .../world/actors/fighters/states/hit2.lua | 20 ++++++++++++++++++ .../world/actors/fighters/states/hit3.lua | 16 ++++++++++++++ .../world/actors/fighters/states/idle.lua | 7 +++++++ .../world/actors/fighters/states/init.lua | 3 +++ 7 files changed, 80 insertions(+), 11 deletions(-) create mode 100644 sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit1.lua create mode 100644 sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit2.lua create mode 100644 sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit3.lua diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/controls.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/controls.lua index ed110af..d455990 100644 --- a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/controls.lua +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/controls.lua @@ -1,17 +1,23 @@ local PlayerControls = Object:extend() function PlayerControls:applyInputs() - if (self.world.autorun == true) then - self:applyAutorunInput() - else - self:applyMoveInput() - end + self:applyMoveInput() self:applyJumpInput() self:applyActionsInputs() self:applySwitchInputs() end function PlayerControls:applyMoveInput() + if (self:getStateVar("canMove", false)) then + if (self.world.autorun == true) then + self:applyAutorunInput() + else + self:applyFreemoveInput() + end + end +end + +function PlayerControls:applyFreemoveInput() local angle, strenght = self:dpadToAngle() if (strenght ~= 0) then self:goTowardDir(angle, strenght) @@ -62,8 +68,9 @@ end function PlayerControls:applyActionsInputs() - if self.keys["B"].isPressed and (self.onGround) then - -- Nothing for the moment + if self.keys["B"].isPressed then + --self:setState("hit1") + self:playStateFunc("bAction") end end diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/init.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/init.lua index 33c43cf..dad14f3 100644 --- a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/init.lua +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/player/init.lua @@ -38,10 +38,6 @@ function Player:timerResponse(response) end end -function Player:animationEnded(name) - -end - function Player:getViewCenter() local x, y = Player.super.getViewCenter(self) return x, y-16 diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit1.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit1.lua new file mode 100644 index 0000000..b4bd926 --- /dev/null +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit1.lua @@ -0,0 +1,20 @@ +local hit1state = {} + +hit1state.canSwitch = false +hit1state.canJump = false +hit1state.defaultAnim = false +hit1state.canMove = false + +function hit1state:start() + self.sprite:changeAnimation("hit1", true) +end + +function hit1state:bAction() + self:setState("hit2") +end + +function hit1state:animationEnded() + self:setState("idle") +end + +return hit1state \ No newline at end of file diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit2.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit2.lua new file mode 100644 index 0000000..d3e9d12 --- /dev/null +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit2.lua @@ -0,0 +1,20 @@ +local hit1state = {} + +hit1state.canSwitch = false +hit1state.canJump = false +hit1state.defaultAnim = false +hit1state.canMove = false + +function hit1state:start() + self.sprite:changeAnimation("hit2", true) +end + +function hit1state:bAction() + self:setState("hit3") +end + +function hit1state:animationEnded() + self:setState("idle") +end + +return hit1state \ No newline at end of file diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit3.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit3.lua new file mode 100644 index 0000000..712ee4a --- /dev/null +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/hit3.lua @@ -0,0 +1,16 @@ +local hit1state = {} + +hit1state.canSwitch = false +hit1state.canJump = false +hit1state.defaultAnim = false +hit1state.canMove = false + +function hit1state:start() + self.sprite:changeAnimation("hit3", true) +end + +function hit1state:animationEnded() + self:setState("idle") +end + +return hit1state \ No newline at end of file diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/idle.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/idle.lua index 525e969..6e2a9c7 100644 --- a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/idle.lua +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/idle.lua @@ -3,5 +3,12 @@ local idleState = {} idleState.canSwitch = true idleState.canJump = true idleState.defaultAnim = true +idleState.canMove = true + +function idleState:bAction() + if (self.onGround) then + self:setState("hit1") + end +end return idleState \ No newline at end of file diff --git a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/init.lua b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/init.lua index 92e78a1..16c2ab1 100644 --- a/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/init.lua +++ b/sonic-radiance.love/game/modules/subgames/world/actors/fighters/states/init.lua @@ -1,3 +1,6 @@ return { "idle", + "hit1", + "hit2", + "hit3", } \ No newline at end of file