Display animated Leaf Ranger
This commit is contained in:
parent
c9dfd13823
commit
c450fc0efb
24
main.lua
24
main.lua
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue