{"name":"lofi 3d 3","description":"-- lofi 3d 3\n-- alexthescott\n-- 10/25/21 9:01pm\n\n-- based on 3d demo\n-- by @noahrosamilia\n\n-- circle maths \n-- https://www.cmu.edu/biolphys/deserno/pdf/sphere_equi.pdf\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\nfunction draw_shape(s)\n\tfor i,l in ipairs(s[2]) do\n\t\tdraw_line(s[1][l[1]],s[1][l[2]],i)\n\tend\nend\n\nfunction draw_line(p1,p2,c)\n\tx0,y0=project(p1)\n\tx1,y1=project(p2)\n\tline(x0,y0,x1,y1,c)\nend\n\nfunction draw_point(p,c)\n\tx,y=project(p)\n\tpset(x,y,c)\nend\n\nfunction project(p)\n\t-- calculate x,y and center it\n\tx=(p[1]-cam[1])*mult/(p[3]-cam[3])+127/2\n\ty=-(p[2]-cam[2])*mult/(p[3]-cam[3])+127/2\n\treturn x,y\nend\n\nfunction translate_shape(s,t)\n\t-- copy shape, 0 out points,\n\t-- keep og lines\n\tns={{},s[2]}\n\t-- add displacement to point\n\tfor p in all(s[1])do\n\t\tadd(ns[1],{p[1]+t[1],p[2]+t[2],p[3]+t[3]})\n\tend\n\treturn ns\nend\n\nfunction rotate_shape(s,a,r)\n\t-- copy shape, 0 out points\n\t-- keep og lines\n\tns={{},s[2]}\n\tfor p in all(s[1])do\n\t\tadd(ns[1],rotate_point(p,a,r))\n\tend\n\treturn ns\nend\n\nfunction rotate_point(p,a,r)\n\t-- figure axis we're rotating\n\tif a==1 then\n\t\tx,y,z=3,2,1\n\telseif a==2 then\n\t\tx,y,z=1,3,2\n\telseif a==3 then\n\t\tx,y,z=1,2,3\n\tend\n\t\n\t_x=cos(r)*p[x]-sin(r)*p[y]\n\t_y=sin(r)*p[x]+cos(r)*p[y]\n\tnp={}\n\tnp[x]=_x\n\tnp[y]=_y\n\tnp[z]=p[z]\n\treturn np\nend\n\nfunction limit_int(v,l)\n\tif v>0 then\n\t\treturn min(v,l)\n\telse\n\t\treturn max(v,-l)\n\tend\nend\n\nfunction burn()\n\tfor p=0,384 do\n\t\tx=rnd(128)\\1\n\t\ty=rnd(128)\\1\n\t\tpc=pget(x,y)\n\t\tif pc!=0 then\n\t\t\tpset(x,y,pc-1)\n\t\telse\n\t\t\tpset(x,y,0)\n\t\tend\n\tend\nend\n\nfunction fuzz(big)\n\tif big then\n\t\tsz=10\n\t\tcnt=512\n\telse\n\t\tsz=3\n\t\tcnt=384\n\tend\n\n\tfor p=0,cnt do\n\t\tx=rnd(128)\\1\n\t\ty=rnd(128)\\1\n\t\tpc=pget(x,y)\n\t\tif pc!=0 then\n\t\t\tfor l=1,rnd(sz)\\1 do\n\t\t\tpset(x-l,y,pc)\n\t\t\tpset(x+l,y,pc)\n\t\t\tend\n\t\tend\t\t\n\tend\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\nfunction build_circ(shape,n,s)\n\tphi=2*(3-sqrt(5))\n\tfor i=0,n do\n\t\ty=1-(i/(n-1))*2\n\t\tr=sqrt(1-y*y)\n\t\ttheta=phi*i\n\t\tx=cos(theta)*r\n\t\tz=sin(theta)*r\n\t\tadd(shape[1],{x*s,y*s,z*s})\n\tend\n\t\n\tfor i=1,#shape[1]-2 do\n\t\tadd(shape[2],{i,i+2})\n\tend\nend\n\nfunction centr_circ(r,c)\n\t\tfor x=0,128 do\n\t\t\ty=sqrt(r^2-(x-64)^2)+64\n\t\t\tline(x,128,x,y,c)\n\t\t\tline(x,0,x,128-y,c)\n\t\tend\nend\n\nfor i=1,rnd()*16 do\n\tforward()\nend\n\nfor p=1,24 do\n\tpo={p,p+1}\nend\n\ncam={0,0,-1.5}\nmult=64\n\ncir1={{},{}}\ncir2={{},{}}\nbuild_circ(cir1,256,1)\nbuild_circ(cir2,128,2/3)\ncir2=rotate_shape(cir2,1,0.25)\n\nburn_count=10+(50*rnd())\\1\nburn_var=3+(10*rnd())\\1\n\ncntr_dthr=rnd()<=0.25\n\na=1+rnd(2)\\1\nac=(1+rnd(10)\\1)*60\n\nmonth=stat(81)\nday=stat(82)\ncls()\n_set_fps(60)\n::♥::\nif t()<2 then\n\tprint(\"lofi 3d 3\",46,59,1)\n\tprint(month..\"/\"..day,55,65)\nelse\n\tif btn(❎) and btn(🅾️) or \n\t\ttime()%burn_var==0 then\n\t\t\tburn_count=10+(50*rnd())\\1\n\t\t\tburn_var=3+(10*rnd())\\1\n\t\t\tcentr_circ(64,0)\n\telseif burn_count>0 then\n\t\tcentr_circ(64,0)\n\t\tburn_count-=1\n\telse\n\t\tcentr_circ(32,0)\n\t\tif cntr_dthr then\n\t\t\tfillp(0b0111010101111111)\n\t\t\tcircfill(63,63,32,1)\n\t\t\tfillp()\n\t\tend\n\tend\n\t\n\tif btn(⬅️) then cam[1] -= 0.01 end\n\tif btn(➡️) then cam[1] += 0.01 end\n\tif btn(⬆️) then cam[2] += 0.01 end\n\tif btn(⬇️) then cam[2] -= 0.01 end\n\tif btn(❎) then cam[3] -= 0.01 end\n\tif btn(🅾️) then cam[3] += 0.01 end\n\t\n\tif btn(⬆️) and btn(⬇️) or\n\t\tbtn(➡️) and btn(⬅️) then\n\t\t\tprint(\"cam.x=\"..cam[1],0,0,2)\n\t\t\tprint(\"cam.y=\"..cam[2],0,6,2)\n\t\t\tprint(\"cam.z=\"..cam[3],0,12,2)\n\tend\n\t\n\tif ac<=0 then\n\t\tif a==1 then\n\t\t\ta=2\n\t\telse\n\t\t\ta=1\n\t\tend\n\t\tac=(1+rnd(10)\\1)*60\n\telse\n\t\tac-=1\n\tend\n\t\n\tcir2=rotate_shape(cir2,a,0.004)\n\tcir1=rotate_shape(cir1,a,0.004)\n\tdraw_shape(cir2)\n\tdraw_shape(cir1)\nend\nflip()\ngoto ♥","tags":["pico-8","pico8","interactive"],"symbol":"OBJKT","artifactUri":"ipfs://Qma38DmzYYJRxCXh9z3rFgsG5G6zShjUa9oPCN5qArUvtn","displayUri":"ipfs://QmPbWN8zAF8thj9xxxVP9cq44CmZyumabf6QtgHmSdRx6A","thumbnailUri":"ipfs://QmNrhZHUaEqxhyLfqoq1mtHSipkWHeT31LNHb1QEbDHgnc","creators":["tz1St3n29AbYXZXV8W1BG41qYzz86J2CFAW7"],"formats":[{"uri":"ipfs://Qma38DmzYYJRxCXh9z3rFgsG5G6zShjUa9oPCN5qArUvtn","mimeType":"application/x-directory"}],"decimals":0,"isBooleanAmount":false,"shouldPreferSymbol":false}