PICO-8 Tweetcart Studies

Back to main menu


Tunnel

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

Tunnel

Display Palette

0
12
1
2
-8
8
14
15
-1
-7
9
10

Summary

This is a tunnel that only uses simple circles. To fill in the empty space, it doesn’t call cls() at the start of each frame and uses the colours that already exist on the screen (see the cls-vs-dithering page for some more info on this technique).

Pictures

This is how many pixels get drawn each frame. The black space is empty and where the previous frame's colours would show through.

The effect without the 'time shifting' on st. Doesn't look that interesting – the strange, kinda-wonky time shifting gives it character.

Tweet code

pal({12,1,2,-8,8,14,15,-1,-7,9,10},1)::w::st=t()/2for i=1,250 do
st -= .001+sin(st/5)*.003circ(64+sin(st)*30,64+cos(st)*30,i/2,(i*.044-t()*10)%11+1)end
flip()goto w

Breakdown

-- setup the display palette
pal({12,1,2,-8,8,14,15,-1,-7,9,10},1)

-- start of rendering loop
::w::
-- get initial scene time
st=t()/2

-- from the centre of the tunnel to the outside
for i=1,250 do
  -- the centre of the tunnel is in the 'future', so the
  --  outside of the tunnel is the past... so we minus
  --  time as we get further from the center.
  --
  -- the '+sin(st/5)*.003' introduces some strange time
  --  shifting that looks really interesting. makes it
  --  look like the tunnel speeds up and slows down.
  st -= .001+sin(st/5)*.003

  -- centre of this part of the tunnel
  x=64+sin(st)*30
  y=64+cos(st)*30

  -- draw the circle!
  -- i/2 means that the circle's radius expands as we
  --  go further out.
  -- i*.44 because that's a nice value, -t()*10 because
  --  that means the pattern is going away from the
  --  center, works with the way we adjust 'st' further
  --  up to create the *going further down the tunnel*
  --  look! if we really wanted to we could coordinate
  --  this with the time shifting above, but oh well.
  -- the %11+1 at the end restricts it to the first 11
  --  colours, and the +1 is to skip the first entry in
  --  pico8's current screen palette (plain black)
  circ(x,y,i/2,(i*.044-t()*10)%11+1)
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