diff --git a/sonic-radiance.love/assets/sprites/charset/perso-punch.png b/sonic-radiance.love/assets/sprites/charset/perso-punch.png new file mode 100644 index 0000000..4092617 Binary files /dev/null and b/sonic-radiance.love/assets/sprites/charset/perso-punch.png differ diff --git a/sonic-radiance.love/assets/sprites/gfx/punch.lua b/sonic-radiance.love/assets/sprites/gfx/punch.lua new file mode 100644 index 0000000..1b21bc1 --- /dev/null +++ b/sonic-radiance.love/assets/sprites/gfx/punch.lua @@ -0,0 +1,18 @@ +return { + metadata = { + width = 32, + height = 28, + defaultAnim = "default", + ox = 0, + oy = 14, + }, + animations = { + ["default"] = { + startAt = 1, + endAt = 4, + loop = 1, + speed = 15, + pauseAtEnd = false, + }, + } +} diff --git a/sonic-radiance.love/assets/sprites/gfx/punch.png b/sonic-radiance.love/assets/sprites/gfx/punch.png new file mode 100644 index 0000000..3b1362b Binary files /dev/null and b/sonic-radiance.love/assets/sprites/gfx/punch.png differ diff --git a/sonic-radiance.love/assets/sprites/punch.png b/sonic-radiance.love/assets/sprites/punch.png new file mode 100644 index 0000000..c9cdcce Binary files /dev/null and b/sonic-radiance.love/assets/sprites/punch.png differ diff --git a/sonic-radiance.love/scenes/overworld/actors/player/actions.lua b/sonic-radiance.love/scenes/overworld/actors/player/actions.lua index 5f162d6..ef1d385 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player/actions.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player/actions.lua @@ -20,6 +20,9 @@ function PlayerActions:canDoAction(action) end function PlayerActions:actionMove() + if (self.currentAction == "punch") then + return + end if (self.currentAction == "jumpdash" or self.currentAction == "run") then self.xsp, self.ysp = utils.math.lengthdir(BASE_SPEED * RUN_FACTOR, math.rad(self.charsetManager.angle[self.charDir])) self.xsp = -self.xsp @@ -112,6 +115,24 @@ function PlayerActions:actionRun() end end +function PlayerActions:actionPunch() + if self.keys["C"].isPressed then + if (self:canDoAction("punch")) then + self.xsp, self.ysp = utils.math.lengthdir(BASE_SPEED * RUN_FACTOR, math.rad(self.charsetManager.angle[self.charDir])) + self.xsp = -self.xsp + self.currentAction = "punch" + self.tweens:newTimer(0.15, "endPunch") + self.assets.sprites["punch"]:changeAnimation("default", true) + end + end +end + +function PlayerActions:endPunch() + if (self.currentAction == "punch") then + self.currentAction = "idle" + end +end + function PlayerActions:endJump() if (self.currentAction == "jump") then self.currentAction = "idle" @@ -129,6 +150,15 @@ function PlayerActions:drawActionEffect() local x, y = self.x + 8 - dx, self.y + 8 - self.z + dy self.assets.sprites["dash"]:drawAnimation(x, y, math.rad(self.charsetManager.angle[self.charDir])) end + if (self.currentAction == "punch") then + local dx, dy = utils.math.lengthdir(20, math.rad(self.charsetManager.angle[self.charDir])) + if (self.charDir == "down") then + dy = 8 + end + local x, y = self.x + 8 - dx, self.y + 8 - self.z + dy + print(x, y) + self.assets.sprites["punch"]:drawAnimation(x, y, math.rad(self.charsetManager.angle[self.charDir])) + end 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 6e16906..b66fa0e 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player/charset.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player/charset.lua @@ -21,6 +21,8 @@ function PlayerCharset:getCharset() charset = charset .. "-jump" elseif (self.currentAction == "fly") then charset = charset .. "-flight" + elseif (self.currentAction == "punch") then + charset = charset .. "-jump" end return charset end diff --git a/sonic-radiance.love/scenes/overworld/actors/player/init.lua b/sonic-radiance.love/scenes/overworld/actors/player/init.lua index 1b95d27..75974c8 100644 --- a/sonic-radiance.love/scenes/overworld/actors/player/init.lua +++ b/sonic-radiance.love/scenes/overworld/actors/player/init.lua @@ -39,6 +39,7 @@ function Player:updateStart(dt) self:actionJump() self:actionSwitch() self:actionRun() + self:actionPunch() self.world:getTileTypeAtPoint(self.x, self.y) @@ -98,6 +99,8 @@ function Player:timerResponse(response) self:endCharacterSwitchAnimation() elseif (response == "endFly") then self:endFly() + elseif (response == "endPunch") then + self:endPunch() end end diff --git a/sonic-radiance.love/scenes/overworld/actors/player/punch.lua b/sonic-radiance.love/scenes/overworld/actors/player/punch.lua new file mode 100644 index 0000000..ad7e759 --- /dev/null +++ b/sonic-radiance.love/scenes/overworld/actors/player/punch.lua @@ -0,0 +1,17 @@ +local Base = require "core.modules.world.actors.actor2D" +local Punch = Base:extend() + +function Punch:new(world, x, y, dir) + Punch.super.new(self, world, "wall", x, y, 8, 8, false) +end + +function Punch:update(dt) + self.depth = -self.y + Punch.super.update(self, dt) +end + +function Punch:draw() + +end + +return Punch \ No newline at end of file diff --git a/sonic-radiance.love/scenes/overworld/assets.lua b/sonic-radiance.love/scenes/overworld/assets.lua index e3a51bb..29d1f0b 100644 --- a/sonic-radiance.love/scenes/overworld/assets.lua +++ b/sonic-radiance.love/scenes/overworld/assets.lua @@ -9,6 +9,7 @@ return { {"cursorground", "assets/gui/cursor/ground"}, {"hitGFX", "assets/sprites/gfx/hit"}, {"encounter", "assets/sprites/encounter"}, + {"punch", "assets/sprites/gfx/punch"}, {"dash", "assets/sprites/gfx/dash"}, }, ["textures"] = {