Skip to content

Instantly share code, notes, and snippets.

@RegBl
Created May 17, 2022 00:17
Show Gist options
  • Save RegBl/a30496873ec18e861026e3a09e03791a to your computer and use it in GitHub Desktop.
Save RegBl/a30496873ec18e861026e3a09e03791a to your computer and use it in GitHub Desktop.
Quick and dirty PICO-8 script to let my artist roommate animate the sprites he's been making.
function _init()
--enter the frame numbers
--in the order you want
--inside the {} separated
--by commas
sprite_sequence={16,17,18,19}
--enter the direction you
--want the sprite to travel
--inside quotes, "right"
--or "left"
heading="right"
p={
x=60,
y=88,
sp=sprite_sequence[1],
sseq=sprite_sequence,
idx=1,
anim=0,
hding=1
}
if heading=="left" then
p.hding=-1
elseif heading=="right" then
p.hding=1
end
cls()
end
function _draw()
cls()
rectfill(0,96,127,127,3)
spr(p.sp,p.x,p.y)
if time()-p.anim>.1 then
p.anim=time()
p.x+=(1*p.hding)
if p.hding==1 then
if p.x>128 then
p.x=-8
end
elseif p.hding==-1 then
if p.x<-8 then
p.x=128
end
end
p.sp=p.sseq[p.idx]
p.idx+=1
if p.idx>count(p.sseq) then
p.idx=1
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment