Skip to content

Instantly share code, notes, and snippets.

@juliaogris
Last active February 16, 2023 10:43
Show Gist options
  • Save juliaogris/808df84d2b4b17e58143811662c38bd6 to your computer and use it in GitHub Desktop.
Save juliaogris/808df84d2b4b17e58143811662c38bd6 to your computer and use it in GitHub Desktop.
dot0 := {x:50 y:5 dx:1 dy:1}
dot1 := {x:75 y:25 dx:1 dy:1}
dot2 := {x:95 y:50 dx:-1 dy:1}
dot3 := {x:75 y:75 dx:-1 dy:1}
dot4 := {x:50 y:95 dx:-1 dy:-1}
dot5 := {x:25 y:75 dx:-1 dy:-1}
dot6 := {x:5 y:50 dx:1 dy:-1}
dot7 := {x:25 y:25 dx:1 dy:-1}
dots := [dot0 dot1 dot2 dot3 dot4 dot5 dot6 dot7]
colors := ["red" "orange" "gold" "forestgreen" "blue" "indigo" "purple" "deeppink"]
while true
clear
for i := range (len dots)
dot dots[i] colors[i]
end
sleep 0.01
end
func clear
color "white"
move 0 0
rect 100 100
end
func dot d:{}num c:string
color c
move d.x d.y
circle 5
d.x = d.x + d.dx
d.y = d.y + d.dy
d.dx = delta d.dx d.x
d.dy = delta d.dy d.y
end
func delta:num d:num n:num
if n <= 5
return 1
else if n >= 95
return -1
else
return d
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment