{"name":"bad flow","description":"-- bad flow\n-- alexthescott\n-- 11/11/21 5:18pm\n\n-- new seed every day of the year \nsrand(31*stat(81)+stat(82)) \n\np1={7,6,135,10,138,11,139,3,131,12,140,1,129,130,128,0}\np2={7,135,10,9,15,143,142,137,14,136,8,2,130,133,128,0}\np3={7,15,143,142,14,8,136,137,9,10,135,138,11,139,12,140}\n\np={p1,p2,p3}\nc=rnd(p)\n\npal(c,1)\n\nglen=8\n\n-- mirror top-left quarter\npoke(0x5f2c, 7) \n\nfunction new_flow()\n\tf={}\n\tf.glen=glen\n\tf.flow={}\n\t\n\t-- build flow\n\tfor ny=0,128,f.glen do\n\t\tfor nx=0,128,f.glen do\n\t\t\tg={x=nx,y=ny}\n\t\t\tif nx==0 and ny==0 then\n\t\t\t\tg.a=((1+rnd(8))\\1)*1/8\n\t\t\telseif ny==0 then\n\t\t\t\tprior_a=f.flow[nx\\f.glen].a\n\t\t\t\tg.a=prior_a+sin(1/((1+rnd(8)\\1)*1/8))\n\t\t\t\tg.a=max(g.a,0.0)\n\t\t\t\tg.a=min(g.a,1)\n\t\t\t\twhile g.a==0 or g.a==0.5 do\n\t\t\t\t\tg.a=prior_a+sin(1/((1+rnd(8)\\1)*1/8))\n\t\t\t\t\tg.a=max(g.a,0.0)\n\t\t\t\t\tg.a=min(g.a,1)\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tprior_a=f.flow[ny\\f.glen+nx\\f.glen].a\n\t\t\t\tg.a=prior_a+sin(rnd())/10\n\t\t\t\tg.a=max(g.a,0.0)\n\t\t\t\tg.a=min(g.a,1)\n\t\t\t\twhile g.a==0 or g.a==0.5 do\n\t\t\t\t\tg.a=prior_a+sin(rnd())/10\n\t\t\t\t\tg.a=max(g.a,0.0)\n\t\t\t\t\tg.a=min(g.a,1)\n\t\t\t\tend\n\t\t\tend\n\t\t\tadd(f.flow,g)\n\t\tend\n\tend\n\t\n\tf.draw=function(self)\n\t\tfor g in all(self.flow) do\n\t\t\trect(g.x,g.y,\n\t\t\t\t\t\t\tg.x+f.glen,g.y+self.glen,3)\n\t\t\n\t\t\t-- draw flow lines\n\t\t\tcx=g.x+self.glen/2\n\t\t\tcy=g.y+self.glen/2\n\t\t\tx_dif=cos(g.a)*self.glen/4\n\t\t\ty_dif=sin(g.a)*self.glen/4\n\t\t\tax=cx-x_dif\n\t\t\tay=cy-y_dif\n\t\t\tbx=cx+x_dif\n\t\t\tby=cy+y_dif\n\t\t\tline(ax,ay,bx,by,7)\n\t\tend\n\tend\n\treturn f\nend\n\nfunction new_bird()\n\tb={}\n\tdist=64\n\td=(rnd()*4)\\1\n\tb.c=14-(rnd()*10)\\1\n\t--small distribution\n\tb.s=rnd(2)/1\n\tif d==0 then\n\t\tb.pos={x=rnd()*128,y=0}\n\telseif d==1 then\n\t\tb.pos={x=127,y=rnd()*128}\n\telseif d==2  then\n\t\tb.pos={x=rnd()*128,y=127}\n\telse\n\t\tb.pos={x=0,y=rnd()*128}\n\tend\n\t\n\tb.pos={x=rnd()*128,y=rnd()*128}\n\t\n\tb.vel={x=0,y=0}\n\t\n\tb.update=function(self)\n\t\tself.pos.x+=self.vel.x\n\t\tself.pos.y+=self.vel.y\n\t\tp=self.pos\n\t\t\n\t\tif p.x<-16 or p.x>144 or\n\t\t\tp.y<-16 or p.y>144 then\n\t\t\t\tval=del(birds,self)\n\t\tend\n\t\t\n\t\ti=1+((p.y\\glen)*(128\\glen)+p.x\\glen)\n\t\tif i<=0 or i>=(128/glen)^2 then\n\t\t\treturn\n\t\telse\n\t\t\tcf=flow.flow[i].a\n\t\t\t\n\t\t\tself.vel.x+=cos(cf)/200\n\t\t\tself.vel.y+=sin(cf)/200\n\t\tend\n\t\t\n\tend\n\t\n\tb.draw=function(self)\n\t\tp=self.pos\n\t\tcircfill(p.x,p.y,self.s,self.c)\n\tend\n\t\n\tb.debug=function(self)\n\t\tp=self.pos\n\t\tprint(p.y,60,48,1)\n\t\tprint(p.x,60,54,1)\n\t\tprint(p.x<-16,1,0,1)\n\t\tprint(p.y<-16,1,6,1)\n\t\tprint(p.x>144,1,12,1)\n\t\tprint(p.x>144,1,18,1)\n\t\tval=p.x<-16 or p.x>144 or\n\t\t\t\tp.y<-16 or p.y>144\n\t\tprint(#birds,1,24,1)\n\tend\n\t\t\n\tadd(birds,b)\nend\n\nfunction forward()\n\tv=c[1]\n\tdel(c,v)\n\tc[#c+1]=v\n\tpal(c,1)\nend\n\nfunction backward()\n\tv=c[#c]\n\tdel(c,v)\n\tfor i=#c+1,1,-1 do\n\t\tif i!=1 then\n\t\t\tc[i]=c[i-1]\n\t\telse\n\t\t\tc[i]=v\n\t\tend\n\tend\n\tpal(c,1)\nend\n\ndir=((rnd(2)\\1)*2)-1\namt=2^((rnd()*3)\\1)\nfuzz_l=rnd()<0.1\nfuzz_r=rnd()<0.1\n\nfunction burn()\n\tfor i=1,512 do\t\n\t\tif i<amt then\n\t\t\tlocal p=0x5ffe+rnd(8128)\\1\n\t\t\tif version==0 then\n\t\t\t\tpoke2(p+64,peek2(p))\n\t\t\t\tpoke2(p+dir,peek2(p))\n\t\t\telseif version==1 then\n\t\t\t\tpoke2(p+64,peek2(p))\n\t\t\t\tpoke2(p+dir,peek2(p)-0.1)\n\t\t\telse\n\t\t\t\tpoke2(p+64,peek2(p)-0.1)\n\t\t\t\tpoke2(p+dir,peek2(p))\n\t\t\tend\n\t\tend\n\t\tx=(128*rnd())\\1\n\t\ty=(128*rnd())\\1\n\t\tpc=pget(x,y)\n\t\tif pc>0 then\n\t\t\tpset(x,y,pc-1)\n\t\t\tif(fuzz_l)pset(x-1,y,pc-1)\n\t\t\tif(fuzz_r)pset(x+1,y,pc-1)\n\t\telse\n\t\t\tcirc(x,y,0,0)\n\t\tend\n\tend\nend\n\nfor i=1,rnd()*16 do\n\tforward()\nend\n\n\nflow=new_flow()\nbirds={}\nnew_bird()\n\nfc=0\n\nseed=rnd()\nsrand(seed)\n\n_set_fps(60)\ncls()\n::♥::\n--cls()\nburn()\n\nif fc%3==0 then\n\tnew_bird()\nend\n\nif fc%600==0 then\n\tfc=0\n\tsrand(seed)\nend\n\n--f:draw()\n\nfor b in all(birds) do\t\n\tb:update()\n\tb:draw()\nend\n--rect(0,0,127,127,2)\n\nfc+=1\n\nif arti==1 then\n\tcirc(80,64,32,10)\n\tcirc(64,80,32,10)\nelseif arti==2 then\n\tcirc(60,60,32,10)\n\tcirc(60,60,32,10)\nend\n\nflip()\ngoto ♥","tags":["pico-8","pico-8"],"symbol":"OBJKT","artifactUri":"ipfs://QmUCJrMF5gChvdsQR6G2kqhZH2cA29iK4YbWbCw1GupekJ","displayUri":"ipfs://QmZk6aziX7YPmoSNDjzUP5GS68NDv5kpHokXCvHvAhZBbr","thumbnailUri":"ipfs://QmNrhZHUaEqxhyLfqoq1mtHSipkWHeT31LNHb1QEbDHgnc","creators":["tz1St3n29AbYXZXV8W1BG41qYzz86J2CFAW7"],"formats":[{"uri":"ipfs://QmUCJrMF5gChvdsQR6G2kqhZH2cA29iK4YbWbCw1GupekJ","mimeType":"application/x-directory"}],"decimals":0,"isBooleanAmount":false,"shouldPreferSymbol":false}