PICO-8 Tweetcart Studies

Back to main menu


Rainbow Tentacles

Author: Daniel Oaks (@pixienop)
Link: https://twitter.com/pixienop/status/1180997046138032129

Rainbow Tentacles

Display Palette

9
137
136
2
141
12
140
1
129
131
3
139
11
138
10
135

Summary

This effect creates tentacles out of circles! The circles near the tip are really tiny, and they get bigger as you get to the base!

The screen palette is setup so that 0->15 is a rainbow (using colours from the secret palette). Every pixel along the tentacle, from the tip to the base, is a separate circle so we can change what colour each one is (which lets us easily create that expanding/retracting look shown above).

Because the circles ‘closer to the camera’ are drawn after the ones near the tip, we also make some nice overlaps that look really interesting and give a 3d look to the bottom tentacle.

Pictures

Each tentacle being drawn, slowly.

How the effect looks without the initial pal() calls to setup the rainbow.

How the effect looks without the 'pulsing'.

Tweet code

p={9,137,136,2,141,12,140,1,129,131,3,139,11,138,10,135}for i,c in pairs(p) do
pal(i-1,c,1)end
cm=0::w:: cm+=1cls(8)st=t()
for b=0,2 do
for i=1,190 do
x=b*30j=x+i
k=40+b*40-20+sin(i*.02+st*.2)*(3+b*5)w=i*.3circfill(j,k,w,i*cos(st*.05)+cm)pset(j-w*.7,k-w*.7,cm)end
end
flip()goto w

Breakdown

-- colours that make up the rainbow pattern
p={9,137,136,2,141,12,140,1,129,131,3,139,11,138,10,135}
-- make 0->15 on the screen render as a rainbow
for i,c in pairs(p) do
  pal(i-1,c,1)
end

-- colour movement adjuster
cm=0

-- start rendering loop
::w::
-- every frame, the colours move 1 further along the
--  tentacles with this variable
cm+=1

-- dark blue background
cls(8)

-- current time
st=t()

-- 0,1,2 - loop and create three tentacles
for b=0,2 do
  -- loop through each 'slice' of the tentacle, from
  --  the smallest circles at the tip, to the big ones
  --  on the right side of the screen
  for i=1,190 do
    -- move the tip of the tentacle 30 pixels to the
    --  right for each one
    x=b*30
    -- (x) midpoint of this slice
    j=x+i
    -- (y) midpoint of this slice
    k=40+b*40-20+sin(i*.02+st*.2)*(3+b*5)
    -- width of this slice - very thin at the tip and
    --  much wider at the base
    w=i*.3
    -- draw the circle for this slice of tentacle
    circfill(j,k,w,i*cos(st*.05)+cm)
    -- draw the tiny 'ridge' that follows the tentacle
    --  along and shows its form off some more
    pset(j-w*.7,k-w*.7,cm)
  end
end

-- display this frame to the screen. if we didn't use
--  flip here, pico-8 would just grab new frames
--  whenever, even if they're not finished yet
flip()
goto w