local Animation = require "animation" local Atlas = require "atlas" local function spannedState(atlas, start, len, on_finish, next) local animation = Animation:new_spanned(atlas, start, start + len - 1) return { animation = animation, on_finish = on_finish, next = next } end 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 local leafRanger = Atlas("assets/leaf-ranger.png", 288, 128, 144, 128) local bringerOfDeath = Atlas("assets/bringer-of-death.png", 140, 93, 105, 93) return { { name = "Leaf Ranger", states = { 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"), } } }