diff --git a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua index 1b045da..c7a3f5e 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua @@ -4,6 +4,10 @@ local Battler = Parent:extend() function Battler:new(world, x, y, z) Battler.super.new(self, world, x, y, z) + self.start = {} + self.start.x = x + self.start.y = y + self.isBattler = true self.speed = 3 self.isActive = false diff --git a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua index 82b8859..a06994c 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua @@ -47,32 +47,21 @@ function Hero:initMovementSystem() self:initJump() end -function Hero:getMovementDuration(dx, dy, factor) - local factor = factor or 1 - local duration = MOVEMENT_DURATION / factor - local coef = 0.5 - local dx, dy = dx, dy - local distance = utils.math.pointDistance(self.x, self.y, dx, dy) * coef - return duration * distance -end - -function Hero:goTo(dx, dy, timerName, factor, easing) +function Hero:goTo(dx, dy, duration, easing) local easing = easing or 'inOutQuad' - local factor = factor or 1 - local duration = math.max(self:getMovementDuration(dx, dy, factor), 0.30) if duration > 0 then self.tweens:newTween(0, duration, {x = dx, y = dy}, easing) end - self.tweens:newTimer(duration + 0.02, timerName) + self.tweens:newTimer(duration + 0.02, "goTo") end -function Hero:jumpTo(dx, dy, size, timerName, spinjump, factor, easing) +function Hero:jumpTo(dx, dy, sizeFactor, duration, spinjump, easing) local easing = easing or 'inOutQuad' - local factor = factor or 1 - local duration = math.max(self:getMovementDuration(dx, dy, factor), 0.30) + local dist = utils.math.pointDistance(self.x, self.y, dx, dy) + local jumpHeight = dist * 8 * sizeFactor self.tweens:newTween(0, duration, {x = dx, y = dy}, easing) - self.tweens:newTimer(duration + 0.02, timerName) - self:setJump(size, spinjump, duration) + self.tweens:newTimer(duration + 0.02, "jumpTo") + self:setJump(jumpHeight, spinjump, duration) end function Hero:updateSpeed(dt) @@ -164,12 +153,16 @@ function Hero:unblockChoregraphy() self.currentlyBlocking = nil end -function Hero:receiveSignal(signal) - if (self.currentlyBlocking ~= nil) then +function Hero:timerResponse(signal) + if ((self.currentlyBlocking ~= nil) and (signal == self.blockedBy)) then self:unblockChoregraphy() end end +function Hero:choregraphyEnded() + self.direction = 1 +end + -- ASSETS FUNCTIONS -- Load and play assets needed by the character