pico-8 cartridge // http://www.pico-8.com version 41 __lua__ function _init() yyl:init() end function _update() yyl:update() end function _draw() cls() yyl:draw() end -->8 -- yoyodyne logo yyl = { ps = {}, filled = {}, ex = 0, ey = 128, vx = 0, vy = -1, done = false, maxt = 20, } function dist(x1, y1, x2, y2) return sqrt( (x2-x1)^2 + (y2-y1)^2 ) end function yyl:init() for x=0,128 do for y=0,100 do seq = 128*y + x -- y stem if y >= 50 and x < 54 and x > 46 then self.filled[seq] = 8 self.filled[seq-6] = 12 end if y >= 50 and x > 75 and x < 82 then self.filled[seq] = 8 self.filled[seq+6] = 12 end -- arms of y if y < 50 and y > 10 then if abs(x-y) < 4 then self.filled[seq] = 8 self.filled[seq-6] = 12 end if abs(128-x-y) < 4 then self.filled[seq] = 8 self.filled[seq+6] = 12 end end -- green o local od = dist(x, y, 64, 30) if od > 10 and od <= 15 then self.filled[seq] = 11 end -- blue o if od > 15 and od < 20 then self.filled[seq] = 12 end end end end function yyl:chk_stop(p) -- round to nearest whole seq = 128*flr(p.y+0.5) + flr(p.x+0.5) if self.filled[seq] == p.c then p.vx = 0 p.vy = 0 p.x = flr(p.x+0.5) p.y = flr(p.y+0.5) self.filled[seq] = true -- note! there is a bug -- nearby, filled is set -- incorrectly sometimes -- not sure why end end function yyl:fill_it_in() -- reset filled as workaround -- for chk_stop bug yyl:init() for i,c in pairs(self.filled) do y = flr(i/128) x = i-(128*y) add(self.ps, {x=x,y=y,c=c,vy=0,vx=0}) end self.done = true end function yyl:update() if not self.done then -- emit pixels for c in all{8, 11, 12} do add(self.ps, {x=self.ex, y=self.ey, c=c, vy=(rnd(2)+1)*self.vy, vx=(rnd(2)+1)*self.vx} ) end -- fill it in? if t() > self.maxt then self:fill_it_in() end -- move emitter if self.ey == 128 and self.ex < 128 then self.ex += 1 self.vx = 0 self.vy = -1 elseif self.ex == 128 and self.ey > 0 then self.ey -= 1 self.vx = -1 self.vy = 0 elseif self.ey == 0 and self.ex > 0 then self.ex -= 1 self.vx = 0 self.vy = 1 else self.ey += 1 self.vx = 1 self.vy = 0 end end -- update pixels for i, p in pairs(self.ps) do if p.vy != 0 or p.vx != 0 then p.x += p.vx p.y += p.vy self:chk_stop(p) if p.y < 0 or p.y > 128 or p.x < 0 or p.x > 128 then deli(self.ps, i) end end end end function yyl:draw() for p in all(self.ps) do pset(p.x, p.y, p.c) end if self.done then print("d", 64, 52, 11) print("y", 64, 58, 11) print("n", 64, 64, 11) print("e", 64, 70, 11) end end __gfx__ 00000000000000bbbbb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000000bbcccccbb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000bcccccccccb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 8000000000bccc88888cccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 c80000000bccc8000008cccb00000008000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 cc8000000bcc800000008ccb0000008c000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ccc800000bcc800000008ccb000008cc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 cccc80000bcc800000008ccb00008ccc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 bcccc8000bccc8000008cccb0008cccc000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0bcccc8000bccc88888cccb0008ccccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00bcccc8000bcccccccccb0008ccccb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000bcccc8000bbcccccbb0008ccccb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000bcccc80000bbbbb00008ccccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000bcccc8000000000008ccccb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000bcccc80000000008ccccb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000bcccc800000008ccccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000bcccc8000008ccccb0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 000000000bccc8000008cccb00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000bcc8000008ccb000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 __sfx__ 000f041e00500005001d550225502255027550275502e5502e55027550275503055027550225501f5501b5501b5501f55022550275502c5502d5502d5502855026550255502655027550245501f5501b55016550