diff --git a/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/init.lua b/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/init.lua index b3f66cc..130cd72 100644 --- a/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/init.lua +++ b/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/init.lua @@ -7,6 +7,8 @@ return { distAttack = false, turns = 2, + hudHeight = 24, + giveExp = 20, giveRings = 30, } diff --git a/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/sprites.lua b/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/sprites.lua new file mode 100644 index 0000000..5be6329 --- /dev/null +++ b/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/sprites.lua @@ -0,0 +1,25 @@ +return { + metadata = { + height = 64, + width = 64, + ox = 32, + oy = 32, + defaultAnim = "idle" + }, + animations = { + ["idle"] = { + startAt = 1, + endAt = 4, + loop = 1, + speed = 12, + pauseAtEnd = false, + }, + ["walk"] = { + startAt = 5, + endAt = 8, + loop = 5, + speed = 12, + pauseAtEnd = false, + } + } +} diff --git a/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/sprites.png b/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/sprites.png new file mode 100644 index 0000000..82fe1d3 Binary files /dev/null and b/sonic-radiance.love/datas/gamedata/ennemies/classics/motobug/sprites.png differ diff --git a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua index 31b43b7..12b67b9 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua @@ -46,6 +46,16 @@ function Battler:draw() love.graphics.setColor(1, 1, 1, 1) end +function Battler:initSprite() + if (self.assets.sprites[self.owner.name] == nil) then + self.assets:addSprite(self.owner.name, self:getSpritePath()) + end + self.assets.sprites[self.owner.name]:setCustomSpeed(16) + self:setSprite(self.owner.name, 32, 48, true) + self:cloneSprite() + self:changeAnimation("idle") +end + function Battler:validateAction() end diff --git a/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua b/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua index edac56b..0b33a79 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua @@ -8,13 +8,15 @@ function Ennemy:new(world, x, y, owner) self.isEnnemy = true self.actionPerTurn = 2 + self:initSprite() + self.direction = -1 end function Ennemy:draw() - Ennemy.super.draw(self) + self:drawSprite(0, -self.z) local x, y = self.world.map:gridToPixel(self.x, self.y, true) - self.owner:drawHUD(x - 12, y - 38) + self.owner:drawHUD(x - 12, y - self.owner.abstract.data.hudHeight) if (self.isSelected) then local height = 32 @@ -26,4 +28,12 @@ function Ennemy:getStats() return self.data.stats end +-- ASSETS FUNCTIONS +-- Load and play assets needed by the character + +function Ennemy:getSpritePath() + return "datas/gamedata/ennemies/" .. self.owner.category .. "/" .. self.owner.name .. "/sprites" +end + + return Ennemy diff --git a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua index eda167c..de89448 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua @@ -206,12 +206,8 @@ end -- ASSETS FUNCTIONS -- Load and play assets needed by the character -function Hero:initSprite() - self.assets:addSprite(self.owner.name, "datas/gamedata/characters/" .. self.owner.name .. "/sprites") - self.assets.sprites[self.owner.name]:setCustomSpeed(16) - self:setSprite(self.owner.name, 32, 48, true) - self:cloneSprite() - self:changeAnimation("idle") +function Hero:getSpritePath() + return "datas/gamedata/characters/" .. self.owner.name .. "/sprites" end function Hero:animationEnded(animation)