parent
84af3076f2
commit
cd0190f065
9 changed files with 71 additions and 0 deletions
BIN
sonic-radiance.love/assets/sprites/charset/perso-punch.png
Normal file
BIN
sonic-radiance.love/assets/sprites/charset/perso-punch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
18
sonic-radiance.love/assets/sprites/gfx/punch.lua
Normal file
18
sonic-radiance.love/assets/sprites/gfx/punch.lua
Normal file
|
@ -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,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
BIN
sonic-radiance.love/assets/sprites/gfx/punch.png
Normal file
BIN
sonic-radiance.love/assets/sprites/gfx/punch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1 KiB |
BIN
sonic-radiance.love/assets/sprites/punch.png
Normal file
BIN
sonic-radiance.love/assets/sprites/punch.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 678 B |
|
@ -20,6 +20,9 @@ function PlayerActions:canDoAction(action)
|
||||||
end
|
end
|
||||||
|
|
||||||
function PlayerActions:actionMove()
|
function PlayerActions:actionMove()
|
||||||
|
if (self.currentAction == "punch") then
|
||||||
|
return
|
||||||
|
end
|
||||||
if (self.currentAction == "jumpdash" or self.currentAction == "run") then
|
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.ysp = utils.math.lengthdir(BASE_SPEED * RUN_FACTOR, math.rad(self.charsetManager.angle[self.charDir]))
|
||||||
self.xsp = -self.xsp
|
self.xsp = -self.xsp
|
||||||
|
@ -112,6 +115,24 @@ function PlayerActions:actionRun()
|
||||||
end
|
end
|
||||||
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()
|
function PlayerActions:endJump()
|
||||||
if (self.currentAction == "jump") then
|
if (self.currentAction == "jump") then
|
||||||
self.currentAction = "idle"
|
self.currentAction = "idle"
|
||||||
|
@ -129,6 +150,15 @@ function PlayerActions:drawActionEffect()
|
||||||
local x, y = self.x + 8 - dx, self.y + 8 - self.z + dy
|
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]))
|
self.assets.sprites["dash"]:drawAnimation(x, y, math.rad(self.charsetManager.angle[self.charDir]))
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
return PlayerActions
|
return PlayerActions
|
||||||
|
|
|
@ -21,6 +21,8 @@ function PlayerCharset:getCharset()
|
||||||
charset = charset .. "-jump"
|
charset = charset .. "-jump"
|
||||||
elseif (self.currentAction == "fly") then
|
elseif (self.currentAction == "fly") then
|
||||||
charset = charset .. "-flight"
|
charset = charset .. "-flight"
|
||||||
|
elseif (self.currentAction == "punch") then
|
||||||
|
charset = charset .. "-jump"
|
||||||
end
|
end
|
||||||
return charset
|
return charset
|
||||||
end
|
end
|
||||||
|
|
|
@ -39,6 +39,7 @@ function Player:updateStart(dt)
|
||||||
self:actionJump()
|
self:actionJump()
|
||||||
self:actionSwitch()
|
self:actionSwitch()
|
||||||
self:actionRun()
|
self:actionRun()
|
||||||
|
self:actionPunch()
|
||||||
|
|
||||||
self.world:getTileTypeAtPoint(self.x, self.y)
|
self.world:getTileTypeAtPoint(self.x, self.y)
|
||||||
|
|
||||||
|
@ -98,6 +99,8 @@ function Player:timerResponse(response)
|
||||||
self:endCharacterSwitchAnimation()
|
self:endCharacterSwitchAnimation()
|
||||||
elseif (response == "endFly") then
|
elseif (response == "endFly") then
|
||||||
self:endFly()
|
self:endFly()
|
||||||
|
elseif (response == "endPunch") then
|
||||||
|
self:endPunch()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
17
sonic-radiance.love/scenes/overworld/actors/player/punch.lua
Normal file
17
sonic-radiance.love/scenes/overworld/actors/player/punch.lua
Normal file
|
@ -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
|
|
@ -9,6 +9,7 @@ return {
|
||||||
{"cursorground", "assets/gui/cursor/ground"},
|
{"cursorground", "assets/gui/cursor/ground"},
|
||||||
{"hitGFX", "assets/sprites/gfx/hit"},
|
{"hitGFX", "assets/sprites/gfx/hit"},
|
||||||
{"encounter", "assets/sprites/encounter"},
|
{"encounter", "assets/sprites/encounter"},
|
||||||
|
{"punch", "assets/sprites/gfx/punch"},
|
||||||
{"dash", "assets/sprites/gfx/dash"},
|
{"dash", "assets/sprites/gfx/dash"},
|
||||||
},
|
},
|
||||||
["textures"] = {
|
["textures"] = {
|
||||||
|
|
Loading…
Reference in a new issue