feat: add damage and ko

Fix #27
This commit is contained in:
Kazhnuz 2020-08-05 11:40:29 +02:00
parent 7be7f6205d
commit a2d0975cde
17 changed files with 103 additions and 6 deletions

Binary file not shown.

View file

@ -0,0 +1,18 @@
return {
metadata = {
height = 32,
width = 32,
defaultAnim = "default",
ox = 16,
oy = 32,
},
animations = {
["default"] = {
startAt = 1,
endAt = 3,
loop = 1,
speed = 15,
pauseAtEnd = false,
},
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -112,5 +112,19 @@ return {
speed = 25, speed = 25,
pauseAtEnd = false, pauseAtEnd = false,
}, },
["hurt"] = {
startAt = 47,
endAt = 49,
loop = 49,
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
startAt = 50,
endAt = 52,
loop = 52,
speed = 15,
pauseAtEnd = true,
}
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View file

@ -112,5 +112,19 @@ return {
speed = 25, speed = 25,
pauseAtEnd = false, pauseAtEnd = false,
}, },
["hurt"] = {
startAt = 55,
endAt = 57,
loop = 57,
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
startAt = 58,
endAt = 62,
loop = 62,
speed = 15,
pauseAtEnd = true,
}
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 47 KiB

View file

@ -112,5 +112,19 @@ return {
speed = 25, speed = 25,
pauseAtEnd = false, pauseAtEnd = false,
}, },
["hurt"] = {
startAt = 49,
endAt = 51,
loop = 51,
speed = 15,
pauseAtEnd = true,
},
["ko"] = {
startAt = 53,
endAt = 59,
loop = 59,
speed = 15,
pauseAtEnd = true,
}
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

After

Width:  |  Height:  |  Size: 59 KiB

View file

@ -47,6 +47,7 @@ function AbstractMobParent:setHP(newHP, relative)
else else
self.hp = newHP self.hp = newHP
end end
self.hp = math.max(0, self.hp)
end end
function AbstractMobParent:setPP(newPP, relative) function AbstractMobParent:setPP(newPP, relative)

View file

@ -228,6 +228,14 @@ function Battler:choregraphyEnded()
self.movementType = MOVEMENT_NONE self.movementType = MOVEMENT_NONE
end end
function Battler:getHurt()
end
function Battler:die()
self:destroy()
end
-- DRAW FUNCTIONS -- DRAW FUNCTIONS
function Battler:draw() function Battler:draw()
local x, y = self.world.map:gridToPixel(self.x, self.y, true) local x, y = self.world.map:gridToPixel(self.x, self.y, true)
@ -250,6 +258,11 @@ function Battler:animationEnded(animation)
if (self.currentlyBlocking ~= nil and self.blockedBy=="animation") then if (self.currentlyBlocking ~= nil and self.blockedBy=="animation") then
self:unblockChoregraphy() self:unblockChoregraphy()
end end
self:getNewAnimation(animation)
end
function Battler:getNewAnimation(animation)
end end
function Battler:validateAction() function Battler:validateAction()

View file

@ -23,6 +23,12 @@ function Ennemy:draw()
end end
end end
function Ennemy:die()
self.assets.sfx["badnicsBoom"]:play()
self.world.obj.GFX(self.world, self.x, self.y, self.z, "boomGFX", self, false)
self:destroy()
end
function Ennemy:getStats() function Ennemy:getStats()
return self.data.stats return self.data.stats
end end

View file

@ -17,6 +17,16 @@ function Hero:update(dt)
self:updateAnimation(dt) self:updateAnimation(dt)
end end
-- HURT/DEATH FUNCTIONS
function Hero:getHurt()
self:changeAnimation("hurt")
end
function Hero:die()
self:changeAnimation("ko")
end
-- ASSETS FUNCTIONS -- ASSETS FUNCTIONS
-- Load and play assets needed by the character -- Load and play assets needed by the character
@ -36,6 +46,12 @@ function Hero:updateAnimation(dt)
self:setCustomSpeed(self.gspeed * 160 * dt) self:setCustomSpeed(self.gspeed * 160 * dt)
end end
function Hero:getNewAnimation(animation)
if (animation == "hurt") then
self:changeAnimation("idle")
end
end
-- DRAW FUNCTIONS -- DRAW FUNCTIONS
-- Draw everything related to the hero -- Draw everything related to the hero

View file

@ -8,6 +8,7 @@ return {
["sprites"] = { ["sprites"] = {
{"cursorground", "assets/gui/cursor/ground"}, {"cursorground", "assets/gui/cursor/ground"},
{"hitGFX", "assets/sprites/gfx/hit"}, {"hitGFX", "assets/sprites/gfx/hit"},
{"boomGFX", "assets/sprites/gfx/boom1"},
}, },
["textures"] = { ["textures"] = {
{"menucursor", "assets/gui/cursor-menulist.png"}, {"menucursor", "assets/gui/cursor-menulist.png"},
@ -43,6 +44,7 @@ return {
{"woosh", "assets/sfx/woosh.wav"}, {"woosh", "assets/sfx/woosh.wav"},
{"spincharge", "assets/sfx/spincharge.wav"}, {"spincharge", "assets/sfx/spincharge.wav"},
{"spinrelease", "assets/sfx/spinrelease.wav"}, {"spinrelease", "assets/sfx/spinrelease.wav"},
{"badnicsBoom", "assets/sfx/badnicsDestroyed.wav"},
{"mBack", "assets/sfx/menus/back.wav"}, {"mBack", "assets/sfx/menus/back.wav"},
{"mBeep", "assets/sfx/menus/beep.wav"}, {"mBeep", "assets/sfx/menus/beep.wav"},

View file

@ -40,6 +40,7 @@ end
function FighterParent:die() function FighterParent:die()
self.isAlive = false self.isAlive = false
self.actor:die()
end end
function FighterParent:sendDamage(target, value, accuracy, isSpecial, isAerial) function FighterParent:sendDamage(target, value, accuracy, isSpecial, isAerial)
@ -68,6 +69,7 @@ function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial)
core.debug:print("cbs/fighter", "Taken " .. value .. " damage" ) core.debug:print("cbs/fighter", "Taken " .. value .. " damage" )
self:setHP(value * -1, true) self:setHP(value * -1, true)
self.actor:getHurt()
end end
function FighterParent:getAbstract() function FighterParent:getAbstract()

View file

@ -72,11 +72,6 @@ function VillainFighter:endAction()
end end
function FighterParent:die()
self.isAlive = false
self.actor:destroy()
end
function VillainFighter:setBonus(pvFactor, statFactor) function VillainFighter:setBonus(pvFactor, statFactor)
self.abstract:setBonus(pvFactor, statFactor) self.abstract:setBonus(pvFactor, statFactor)
end end

View file

@ -50,7 +50,9 @@ function TurnController:update(dt)
if (self.currentFighter ~= nil) then if (self.currentFighter ~= nil) then
self.currentFighter:update(dt) self.currentFighter:update(dt)
else else
self:nextAction() if (self.player:countAlive() > 0) then
self:nextAction()
end
end end
end end
end end