evil-jrpg/units.lua

40 lines
1.3 KiB
Lua
Raw Normal View History

2023-04-20 15:52:35 +00:00
local Animation = require "animation"
local Atlas = require "atlas"
2023-04-20 16:08:56 +00:00
local function spannedState(atlas, start, len, on_finish, next)
2023-04-20 15:52:35 +00:00
local animation = Animation:new_spanned(atlas, start, start + len - 1)
return { animation = animation, on_finish = on_finish, next = next }
end
2023-04-20 16:08:56 +00:00
local function rowState(atlas, row, len, on_finish, next)
local start = (row - 1) * atlas.w + 1
return spannedState(atlas, start, len, on_finish, next)
end
2023-04-21 01:19:17 +00:00
local leafRanger = Atlas("assets/leaf-ranger.png", 288, 128, 144, 128)
local bringerOfDeath = Atlas("assets/bringer-of-death.png", 140, 93, 105, 93)
2023-04-20 15:52:35 +00:00
return {
{
name = "Leaf Ranger",
states = {
2023-04-20 16:08:56 +00:00
idle = rowState(leafRanger, 1, 12),
run = rowState(leafRanger, 2, 10),
hurt = rowState(leafRanger, 16, 6, "goto", "idle"),
death = rowState(leafRanger, 17, 19, "stop"),
}
},
{
name = "Bringer of Death",
states = {
idle = rowState(bringerOfDeath, 1, 8),
walk = rowState(bringerOfDeath, 2, 8),
attack = rowState(bringerOfDeath, 3, 10, "goto", "idle"),
hurt = spannedState(bringerOfDeath, 27, 3, "goto", "idle"),
death = spannedState(bringerOfDeath, 30, 10, "stop"),
cast = spannedState(bringerOfDeath, 40, 9, "goto", "idle"),
spell = spannedState(bringerOfDeath, 49, 16, "stop"),
2023-04-20 15:52:35 +00:00
}
}
}