The Third Day of Tiny Code Christmas Extra
Tiny Code Christmas - Day 3 - EXTRA⌗
Welcome to Day 3 of Tiny Code Christmas EXTRA! We’re glad that you’re joining us again on this festive journey into the world of sizecoding. TCC Extra is intended for people who completed Tiny Code Christmas last year and want a new challenge!
If you haven’t already, read the overview to find out what Tiny Code Christmas is all about!
The Challenge: Connect the Dots!⌗
The first challenge is to make the coolest looking connected dots effect regardless of sizze.
The second challenge is to make the smallest implementation you can of the effect, there’s lots of room for improvement in the code! Check it out below.
TIC-80⌗
x={}
y={}
n=100
function distance(x1,y1,x2,y2)
return math.sqrt(
(x2-x1)*(x2-x1)+
(y2-y1)*(y2-y1)
)
end
for i=1,n do
x[i]=math.random(240)
y[i]=math.random(136)
end
function TIC()
cls(0)
for i=1,n do
for j=1,n do
d=distance(x[i],y[i],x[j],y[j])
if d < 16
then
line(x[j],y[j],x[i],y[i],6)
end
end
circ(x[i],y[i],2,2)
x[i]=(x[i]+(i/120))%240
y[i]=(y[i]+(i/120))%136
end
end
PICO-8⌗
x={}
y={}
n=40
function distance(x1,y1,x2,y2)
return sqrt(
(x2-x1)*(x2-x1)+
(y2-y1)*(y2-y1))
end
for i=1,n do
x[i]=rnd(128)
y[i]=rnd(128)
end
function _draw()
cls(0)
for i=1,n do
for j=1,n do
d=distance(x[i],y[i],x[j],y[j])
if d < 16
then
line(x[j],y[j],x[i],y[i],11)
end
end
circfill(x[i],y[i],2,8)
x[i]=(x[i]+(i/20))%128
y[i]=(y[i]+(i/20))%128
end
end
Sharing is Caring!⌗
If you feel like it, why not share what you’ve done with us on the LoveByte Discord, #lovebyte on IRCnet, or share on Twitter and Mastodon using the hashtag #lovebytetcc