here is the code.
Code: Select all
if os.getenv("LOCAL_LUA_DEBUGGER_VSCODE") == "1" then
require("lldebugger").start()
end
love.graphics.setDefaultFilter("nearest")
local ttfont
local gameoverAnimation
local gameoverloop = true
local img_gameover
local repeating_quad_1
local time = 0
local duration = .2
local animationFrame = 2
function FnGameOver()
local gameOver = {}
gameOver.spriteSheet = love.graphics.newImage('images/gameover.png')
gameOver.quads = {}
table.insert(gameOver.quads, love.graphics.newQuad(0,0, 35, 35, gameOver.spriteSheet:getWidth(), gameOver.spriteSheet:getHeight()))
table.insert(gameOver.quads, love.graphics.newQuad(35,0, 35, 35, gameOver.spriteSheet:getWidth(), gameOver.spriteSheet:getHeight()))
table.insert(gameOver.quads, love.graphics.newQuad(70,0,35,35, gameOver.spriteSheet:getWidth(), gameOver.spriteSheet:getHeight()))
table.insert(gameOver.quads, love.graphics.newQuad(0, 40, 17, 27, gameOver.spriteSheet:getWidth(), gameOver.spriteSheet:getHeight()))
gameOver.duration = 1
gameOver.currentTime = 0
return gameOver
end
function love.load()
img_gameover = love.graphics.newImage('images/gameover.png')
ttfont = love.graphics.newFont('fonts/retro_gaming.ttf', 15)
--gameoverAnimation = FnGameOver()
repeating_quad_1 = love.graphics.newQuad(0,0,35,35, img_gameover)
gameoverAnimation = {
-- G
{
x = 0,
y = 145,
quads = {
repeating_quad_1,
love.graphics.newQuad(0,0, 35, 35, img_gameover),
love.graphics.newQuad(35,0, 35, 35, img_gameover),
love.graphics.newQuad(70,0,35,35, img_gameover),
love.graphics.newQuad(0, 40, 17, 27, img_gameover),
love.graphics.newQuad(0, 73, 17, 27, img_gameover),
love.graphics.newQuad(0, 106, 18, 26, img_gameover)
}
},
-- A
{
x = 35,
y = 145,
quads = {
repeating_quad_1,
love.graphics.newQuad(0,0, 35, 35, img_gameover),
love.graphics.newQuad(35,0, 35, 35, img_gameover),
love.graphics.newQuad(70,0,35,35, img_gameover),
love.graphics.newQuad(40, 80, 17, 27, img_gameover),
love.graphics.newQuad(0, 73, 17, 27, img_gameover),
love.graphics.newQuad(0, 106, 18, 26, img_gameover)
}
}
}
end
function love.draw()
for i = 1, math.floor(animationFrame / 6) do -- highest complete letter (if exists)
local anim = gameoverAnimation[i]
love.graphics.draw(img_gameover, anim.quads[#anim.quads], anim.x, anim.y)
end
--local anim = gameoverAnimation[math.floor(animationFrame / 6)]
--love.graphics.draw(img_gameover, anim.quads[animationFrame % (1 + 1)], anim.x, anim.y)
end
function love.update(dt)
time = time + dt
if time > duration then
animationFrame = animationFrame + 1
time = time - duration
end
end
if i uncomment the local anim .... i get a nil value at the start.
I'm unable to figure out why. Maybe it's a bit too much level for me! hehe
Thanks.