Skip to content

Instantly share code, notes, and snippets.

@jhorikawa
Created November 13, 2020 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhorikawa/0e2ffa18a403a82d8d413745eb926b52 to your computer and use it in GitHub Desktop.
Save jhorikawa/0e2ffa18a403a82d8d413745eb926b52 to your computer and use it in GitHub Desktop.
PICO-8 source code to create traveling circles using sine wave.
r=64
function _draw()
cls(7)
circfill(r,r,r,0)
num=10
speed=0.3
rad=5
seq=0.5
pos={}
for i=0,num do
x=cos(i/(num+1)*0.5)*r
y=sin(i/(num+1)*0.5)*r
line(r-x,r-y,r+x,r+y,5)
pos[i]={x=x,y=y}
end
for i=0,num do
p=pos[i]
offset=i/(num+1)*seq
v=sin(time()*speed+offset)
nx=p["x"]*v
ny=p["y"]*v
rm=1--abs(v)
circfill(nx+r,ny+r,rad*rm,7)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment