Tiny Code Christmas - Day 2 - EXTRA

Welcome to Day 2 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: Enter the Metaverse!

The challenge is to make the smallest implementation you can of a metaball effect, there’s lots of room for improvement on the code! Check it out below.

TIC-80

x1=120
y1=60
x2=120
y2=76

function distance(x1,y1,x2,y2)
 return math.sqrt(
         (x2-x1)*(x2-x1)+
         (y2-y1)*(y2-y1)
        )
end

function TIC()
 t=time()/500
 x1 = (120 + math.sin(t)* 30)
 x2 = (120 + math.cos(t)* 30)
 
 for y=0,135 do
  for x=0,239 do
   d1 = 70/distance(x1,y1,x,y)
   d2 = 70/distance(x2,y2,x,y)
   dist = d1+d2
   pix(x,y,math.min(dist,16))
  end
 end
end

PICO-8

x1=64
y1=60
x2=64
y2=76

function distance(x1,y1,x2,y2)
 return sqrt(
         (x2-x1)*(x2-x1)+
         (y2-y1)*(y2-y1)
        )
end

function _draw()
 t=time()/5
 x1 = (64 + sin(t)* 30)
 x2 = (64 + cos(t)* 30)
 for i=0,1000 do
  x=rnd(128)
  y=rnd(128)

  d1 = 100/distance(x1,y1,x,y)
  d2 = 100/distance(x2,y2,x,y)
  dist = d1+d2
  pset(x,y,min(dist,16))
 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