PICO8 flipbook code
2018 November 10th
-- timer, animation, framerate t = 0 an={4,8,4,8,4,8,4,8,4,8,4,8,0,0,0,0,0,0,0,0,0,0,0} fr=5 -- width+height in sprites w=4 h=4 -- target width+height in px w2=32 h2=32 function _draw() -- background cls(15) rectfill(0,90,128,128,13) -- sprite stretch sspr(ani_helpr(an)%16*8,flr(ani_helpr(an)/16)*8,8*w,8*h,64-w2/2,64-h2/2,w2,h2) end function _update() t+=1 -- timer increase end function ani_helpr(ani) -- given a flipbook table, global framerate, -- and global timer returns which frame of -- anmination the character should be on local index = flr((t % (#ani * fr)) / fr)+1 return ani[index] end -- func ani_helpr