Display animated Leaf Ranger

This commit is contained in:
mars 2023-04-16 17:56:11 -04:00
parent c9dfd13823
commit c450fc0efb
1 changed files with 24 additions and 0 deletions

View File

@ -92,6 +92,16 @@ function love.load()
}
BlockyFont = Font(blockyFont, 8, 8, blockFontChars)
local leafRanger = love.graphics.newImage("assets/leaf-ranger.png")
LeafRanger = {
atlas = Atlas(leafRanger, 288, 128),
step = 0,
duration = 1.0 / 15.0,
frame = 1,
max = 12,
}
end
function love.draw()
@ -100,9 +110,23 @@ function love.draw()
Menu:draw()
BlockyFont:draw("Hello, world!")
love.graphics.draw(LeafRanger.atlas.meshes[LeafRanger.frame])
push:finish()
end
function love.update(dt)
LeafRanger.step = LeafRanger.step + dt
if LeafRanger.step > LeafRanger.duration then
LeafRanger.step = 0
LeafRanger.frame = LeafRanger.frame + 1
if LeafRanger.frame > LeafRanger.max then
LeafRanger.frame = 1
end
end
end
function love.keypressed(key)
if key == "up" then
Menu:up()