My friends and I are in the final part of the development of our game, Zuli, but we are facing a big problem with the animation of the "final boss".
Have tried several solutions, including PO2 tried to use, but nothing works and the game continues to show a white rectangle instead of animating the final boss.
Here is the code used in the final boss of the game (file "enemy.lua" at level 12):
Code: Select all
require("general/player")
--animations
require("general/aNal")
local zoll=love.graphics.newImage("images/zoll.png")
zoll:setFilter("linear", "linear")
zollAnimation = newAnimation(zoll, 560, 512, 0.1, 15)
local zoll2=love.graphics.newImage("images/zollroar.png")
zoll2:setFilter("linear", "linear")
--zollRoar = newAnimation(zoll2, 560, 512, 0.1, 15)
zollRoar = newAnimation(zoll2, 1024, 1024, 0.15, 8)
local zoll3=love.graphics.newImage("images/zollpunch.png")
zoll3:setFilter("linear", "linear")
zollPunch = newAnimation(zoll3, 560, 512, 0.136, 11)
local zoll4=love.graphics.newImage("images/zollkick.png")
zoll4:setFilter("linear", "linear")
zollKick = newAnimation(zoll4, 560, 512, 0.1, 15)
--death animation
local disint=love.graphics.newImage("images/disintegrate.png")
disint:setFilter("nearest", "nearest")
local hit = newAnimation(disint, 63, 83, 0.1, 10)
local minihit = newAnimation(disint, 63, 83, 0.1, 10)
local drawMiniHit = false
--ress zulu anime
local ress = love.graphics.newImage("images/smoke.png")
ress:setFilter("nearest", "nearest")
local smoke = newAnimation(ress, 56, 51, 0.1, 19)
local drawSmoke = false
local rnd = math.random
local flr = math.floor
local ceil = math.ceil
local max = math.max
local HP = love.graphics.newFont(26)
local actualAnime = 1
local levelWidth
local levelHeight
local hitX
local hitY
local cooldownRoar = 4
local cooldownPunch = 4
local cooldownKick = 4
local cooldownZulus = 10
function createZoll ()
levelWidth = ceil(love.graphics.getWidth()*scaleX)
levelHeight = ceil(love.graphics.getHeight()*scaleY)
objects.zollShape = {}
objects.zollShape.body = love.physics.newBody(world, 1700,1000, 'static')
objects.zollShape.shape = love.physics.newRectangleShape(200*2, 637*2)
objects.zollShape.fixture = love.physics.newFixture( objects.zollShape.body, objects.zollShape.shape, 5)
objects.zollShape.life = 20
createKillBox ()
end
function createKillBox ()
objects.killBox = {}
objects.killBox.body = love.physics.newBody(world, 9999,700, 'static')
objects.killBox.shape = love.physics.newCircleShape(200)
objects.killBox.fixture = love.physics.newFixture( objects.killBox.body, objects.killBox.shape, 1)
end
function drawZoll ()
if objects.zollShape ~= -1 then
--love.graphics.rectangle("fill", 0, 0, math.ceil(love.graphics.getWidth()*scaleX),math.ceil(love.graphics.getHeight()*scaleY) )
--love.graphics.setColor(0, 200, 0)
--love.graphics.setColor(250, 250, 250)
--love.graphics.print("X:" .. objects.zollShape.body:getX(), objects.zollShape.body:getX()-100, objects.zollShape.body:getY()-120)
--love.graphics.print("Y:" .. objects.zollShape.body:getY(), objects.zollShape.body:getX()-100, objects.zollShape.body:getY()-100)
love.graphics.setColor(200, 0, 0)
love.graphics.setFont(HP)
love.graphics.print("HP "..objects.zollShape.life, objects.zollShape.body:getX()-130, 130)
love.graphics.setColor(250, 250, 250)
if actualAnime == 1 then
zollAnimation:draw( 950,220,0,2.5,2.5)
elseif actualAnime == 2 then
--zollRoar:draw( 950,220,0,2.5,2.5)
zollRoar:draw(600,-500,0,2,2)
elseif actualAnime == 3 then
zollPunch:draw( 950,220,0,2.5,2.5)
elseif actualAnime == 4 then
zollKick:draw( 950,220,0,2.5,2.5)
end
--love.graphics.polygon("line", objects.zollShape.body:getWorldPoints(objects.zollShape.shape:getPoints()))
--love.graphics.circle("line", objects.killBox.body:getX(),objects.killBox.body:getY(), objects.killBox.shape:getRadius())
if drawMiniHit then
minihit:draw(hitX, hitY)
end
if drawSmoke then
local cont
for cont = 1,3 do
if objects.eShape[cont] ~= -1 then
--smoke:draw(objects.eShape[cont].x, objects.eShape[cont].y,0,2,2)
end
end
end
if objects.zollShape.life == 0 then
love.graphics.setColor(255, 255, 255)
hit:draw(objects.zollShape.body:getX()-100, objects.zollShape.body:getY()-637,0,10,10)
end
end
end
--[[
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Zoll IA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
]]
function moveZoll(dt)
cooldownRoar = max ( 0, cooldownRoar - dt )
cooldownPunch = max ( 0, cooldownPunch - dt )
cooldownKick = max ( 0, cooldownKick - dt )
if gamestate == 'playing' then
smoke:update(dt)
if smoke:getCurrentFrame() == 17 then
drawSmoke= false
end
minihit:update(dt)
if minihit:getCurrentFrame() == 10 then
drawMiniHit = false
end
if objects.zollShape.life ~= 0 then
zollAnimation:update(dt)
zollPunch:update(dt)
zollKick:update(dt)
zollRoar:update(dt)
if actualAnime == 1 then
checkAttackRoar ()
checkAttackPunch ()
checkAttackKick ()
end
--setKillBox()
stopRoar()
stopPunch()
stopKick()
--respawnZulus(dt)
elseif objects.zollShape ~= -1 then
hit:update(dt)
if hit:getCurrentFrame() == 10 then
objects.zollShape.body:destroy()
gamestate = "gameend"
objects.zollShape = -1
hit:seek(1)
end
end
end
end
function zollHitBySonar (x,y)
minihit:seek(1)
drawMiniHit = true
hitX = x
hitY = y
love.audio.play(pain)
end
function checkAttackRoar ()
if cooldownRoar == 0 then
zollDoRoar()
end
end
function checkAttackPunch ()
if cooldownPunch == 0 then
zollDoPunch()
end
end
function checkAttackKick ()
if cooldownKick == 0 then
zollDoKick()
end
end
function findPlayer()
if objects.player.body:getY() < 637*2/3+250 then
return "top"
elseif objects.player.body:getY() < 637*2*2/3+250 and objects.player.body:getY() > 637*2/3+250 then
return "mid"
elseif objects.player.body:getY() > 637*2*2/3+250 then
return "bot"
end
end
function zollDoRoar()
if findPlayer() == "top" then
actualAnime = 2
zollRoar:play()
end
end
function zollDoPunch()
if findPlayer() == "mid" then
actualAnime = 3
zollPunch:play()
end
end
function zollDoKick()
if findPlayer() == "bot" then
actualAnime = 4
zollKick:play()
end
end
function playBasicAnime()
actualAnime = 1
love.audio.play(zollNoise)
zollAnimation:play()
end
function stopRoar()
if zollRoar:getCurrentFrame() == 15 then
zollRoar:stop()
zollRoar:seek(1)
cooldownRoar = 4
playBasicAnime()
end
end
function stopPunch()
if zollPunch:getCurrentFrame() == 11 then
zollPunch:stop()
zollPunch:seek(1)
cooldownPunch = 4
playBasicAnime()
end
end
function stopKick()
if zollKick:getCurrentFrame() == 15 then
zollKick:stop()
zollKick:seek(1)
cooldownKick = 4
playBasicAnime()
end
end
function respawnZulus(dt)
local contKilleds = 0
if playerLive then
for cont=1,3 do
if objects.eShape[cont] == -1 then
contKilleds = contKilleds + 1
end
end
if contKilleds == 3 then
cooldownZulus = max ( 0, cooldownZulus - dt )
end
if cooldownZulus == 0 then
createEnemy12 ()
contKilleds = 0
cooldownZulus = 10
end
end
end
function setKillBox()
if actualAnime == 2 then
if zollRoar:getCurrentFrame() > 5 and zollRoar:getCurrentFrame() < 8 then
objects.killBox.body:setPosition(1350,560)
love.audio.play(roar)
else
objects.killBox.body:setPosition(9999,700)
end
end
if actualAnime == 3 then
if zollPunch:getCurrentFrame() > 9 and zollPunch:getCurrentFrame() < 11 then
objects.killBox.body:setPosition(1300,800)
love.audio.play(punch)
else
objects.killBox.body:setPosition(9999,700)
end
end
if actualAnime == 4 then
if zollKick:getCurrentFrame() > 11 and zollKick:getCurrentFrame() < 15 then
objects.killBox.body:setPosition(1300,1250)
else
objects.killBox.body:setPosition(9999,700)
end
end
end
-----------------------------------------------------------------------------------------------------------------------------------
function createEnemy12 ()
local cont = 0
objects.eShape = {}
--for cont=1, 3 do
makeEnemies12(cont)
--end
end
function makeEnemies12(cont)
objects.eShape[cont] = {}
if cont == 1 then
objects.eShape[cont].x =900
objects.eShape[cont].y =300
elseif cont == 2 then
objects.eShape[cont].x =900
objects.eShape[cont].y =700
elseif cont == 3 then
objects.eShape[cont].x =1100
objects.eShape[cont].y =1100
end
smoke:seek(1)
drawSmoke = true
objects.eShape[cont].body = love.physics.newBody(world, objects.eShape[cont].x,objects.eShape[cont].y , "dynamic")
objects.eShape[cont].shape = love.physics.newCircleShape(22)
objects.eShape[cont].fixture = love.physics.newFixture(objects.eShape[cont].body, objects.eShape[cont].shape, 2)
objects.eShape[cont].facing = 1
objects.eShape[cont].life = 1
end
----
Note: We are still using version 0.8.0 of Love.
Note [2]: .love file: https://bitbucket.org/MinusOneGames/zul ... /Zuli.love