Hi all,
I have just started experimenting with TIC 80 and am sort of stuck animating a 2x3 sprite (refer to attached image).
I would like to animate it when moving (pressing left and right arrow) in a smooth way (not glitchy).
x=10 y=80 sn=0 function aspr() sn=0+t%16//8*2 end function TIC() cls(7) spr(sn,x,y,1,1,0,0,2,3) if btn(2) then aspr(); x=x-0.5 elseif btn(3) then aspr(); x=x+0.5 else sn=0 end end
Obviously this code is far from perfect. Let's say it works but if I quickly press and release the arrow keys the player sort of slides without being animated.
The sprite is not mine (I am just experimenting as I said) but I would like a smooth walking transition. I thought of changing the aspr() values to 16 and 8 to quickly cycle between the sprites. I am also incrementing x by 0.5 no to make the player go so fast. Not sure if I am doing well.
Can someone give me a helping hand to optimise the code in the correct way?
Thanks in advance