Pickin Poop
Released Pickin’ Poop, a game made in Pico 8.
I got a lot of use out of this animate
function which will take in an object with the required animation properties and animate them.
An example an object that would be sent to the function.
{
frames={1,2}, -- refers to sprite numbers
length = 10, -- how many ticks to display a frame for
index = 1, -- current index of the frames list
counter=0, -- counts up to the value of length and then increments the index
loop = true, -- wrap around to index = 1 once the end of the list is reached
ended = false -- set to true when end of frames is reached and loop is set to false
}
function animate(a)
-- no calculations needed for a single frame
if #a.frames == 1 then return end
if a.ended and a.loop == false then
return
end
a.counter += 1
if a.counter >= a.length then
a.counter = 0
a.index += 1
if a.index > #a.frames then
if a.loop == false then
a.ended = true
a.index -= 1
else
a.index = 1
end
end
end
end