sonic-radiance/sonic-radiance.love/scenes/battlesystem/actors/hero.lua

47 lines
947 B
Lua

local Battler = require("scenes.battlesystem.actors.battler")
local Hero = Battler:extend()
-- INIT FUNCTIONS
-- Initialize the hero
function Hero:new(world, x, y, owner, charnumber)
Hero.super.new(self, world, x, y, 0, owner)
self:initSprite()
end
-- UPDATE FUNCTION
-- Update the hero
function Hero:update(dt)
Hero.super.update(self, dt)
self:updateAnimation(dt)
end
-- ASSETS FUNCTIONS
-- Load and play assets needed by the character
function Hero:getSpritePath()
return "datas/gamedata/characters/" .. self.owner.name .. "/sprites"
end
function Hero:updateAnimation(dt)
if (self.z > 0 and self.jump.useDefaultAnimation) then
if self.zspeed > 0 then
self:changeAnimation("jump")
else
self:changeAnimation("fall")
end
end
self:setCustomSpeed(self.gspeed * 160 * dt)
end
-- DRAW FUNCTIONS
-- Draw everything related to the hero
function Hero:draw()
self:drawSprite(0, -self.z)
end
return Hero