Frame (rectangle with a duration and optional collection of attachments)
Animation set (a set of animations)
Animation script (a script that specifies a set of animations - see below)
Animation data (immutable description of an animation set that multiple independent animation sets can refer to)
Animation sets can be created programmatically or described inline using a DSL.
Ideal look'n'feel:
-- create animation set programmatically
local as = aset.new()
local walk = as:addanimation('walk')
local f = walk:addframe(x,y,w,h,duration) -- duration can be in a format like '0.1s' or '100ms'
f:addattachment('lefthand',x,y)
walk:addframe(x,y,w,h,duration)
walk:addframe(x,y,w,h,duration)
as:play('walk')
function love.update(dt)
-- animation sets need to be able to flip frames so they need to know about time passing
as:update(dt)
end
function love.draw()
local offsx, offsy = as:attachment('lefthand')
love.graphics.draw(sword, objx + offsx, objy + offsy)
love.graphics.draw(player, objx, objy, as:frame())
end
-- there should be a DSL module to make this look more descriptive
-- this module should let you load from a file:
local as = dsl.loadfile('path/to/anim/script.lua')
-- or describe it inline:
local as = dsl.run(function()
animation 'idle' {
frame {
source = {x,y,w,h}, duration = '0.1s',
attachments = {
lefthand = {16,16}
}
-- alternately?: attachment 'lefthand' {16,16}
},
frame { ... }
}
animation 'walk' { ... }
end)
Things I've found a need for during LD32 and will be adding:
[x] Arbitrary userdata stored per frame
Because I didn't have time to plan this out ahead of time I ended up storing bullet radius in an attachment as the X component - yuck
Userdata is just a generalization of attachments
[x] Quads stored per frame
Generally useful for rendering from image to screen based on the source of a frame
How do we get the reference width and height?
[x] Animator states like 'playing', 'paused', etc.
[x] Way to know if an animator has played through an animation once, or maybe a way to have an animator stop animating once it has gone through an animation
Should probably use an event emitter implementation, see #22
[ ] More animation options?
repeat = 'none|once|pingpong' | 123 | false?
next = 'otheranimationname'?
Can be specified at the animation 'name' {...} level
[x] Allow extending of the DSL function environment.
I'm going to merge everything so far (79d71d5fde970b77707013ebd2af61c6726e023e) into master then work on the rest post-LD33. Shouldn't be any breaking changes.
API concepts:
Animation sets can be created programmatically or described inline using a DSL.
Ideal look'n'feel:
Things I've found a need for during LD32 and will be adding:
repeat = 'none|once|pingpong' | 123 | false
?next = 'otheranimationname'
?animation 'name' {...}
levellove.filesystem
? I used this model in LD27.