{"name":"lofi 3d 4","description":"-- lofi 3d 4\n-- alexthescott\n-- 11/2/21 6:09pm\n-- In celebration of HEN500K :)\n\n-- based on 3d demo\n-- by @noahrosamilia\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]],max(1,i%16))\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 burn()\n\tloop_count=512\n\tif(burn_type) loop_count=256\n\tfor p=0,loop_count 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\t\tif burn_type and rnd()<0.5 then\n\t\t\t\tpset(x-1,y,pc-1)\n\t\t\t\tpset(x+1,y,pc-1)\n\t\t\t\tpset(x,y-1,pc-1)\n\t\t\t\tpset(x,y+1,pc-1)\n\t\t\tend\n\t\telse\n\t\t\tpset(x,y,0)\n\t\tend\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 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\nfunction build_plane(shp)\n\tfor x=-1,1,0.25 do\n\t\tfor y=-1,1,0.25 do\n\t\t\tadd(shp[1],{x,y,0})\n\t\tend\n\tend\n\t\n\tfor x=-1,1,0.25 do\n\t\tfor z=-1,1,0.25 do\n\t\t\tadd(shp[1],{x,0,z})\n\t\tend\n\tend\n\t\n\tfor y=-1,1,0.25 do\n\t\tfor z=-1,1,0.25 do\n\t\t\tadd(shp[1],{0,y,z})\n\t\tend\n\tend\n\t\n\tfor p=1,#shp[1]-1 do\n\t\tif p%9!=0 then\n\t\t\tadd(shp[2],{p,p+1})\n\t\tend\n\tend\nend\n\nfunction build_circ(shp)\n\tp=32\n\tz=0\n\tfor i=0,p do\n\t\tx=cos(i/p)*1.1\n\t\ty=sin(i/p)*1.1\n\t\tadd(shp[1],{x,y,z})\n\tend\n\t\n\tfor p=1,#shp[1]-1 do\n\t\tif p%9!=0 then\n\t\t\tadd(shp[2],{p,p+1})\n\t\tend\n\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,-2.1}\nmult=64\n\nshape={{},{}}\nbuild_plane(shape)\n\no1={{},{}}\nbuild_circ(o1)\no1=rotate_shape(o1,2,0.25)\no2={{},{}}\nbuild_circ(o2)\no2=rotate_shape(o2,2,0.25)\no2=rotate_shape(o2,3,0.25)\no3={{},{}}\nbuild_circ(o3)\n\ndir=(1+rnd()*3)\\1\nburn_type=rnd()<0.5\nshow_circ=rnd()<0.5\n\nfc=0\nmonth=stat(81)\nday=stat(82)\ncls()\n_set_fps(60)\n::♥::\nif t()<2 then\n\tprint(\"lofi 3d 4\",46,59,1)\n\tprint(month..\"/\"..day,55,65)\nelse\n\tif btn(❎) and btn(🅾️) then\n\t\tcls()\n\telse\n\t\tburn()\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 fc%500==0 then\n\t\tfc=0\n\t\tdir=(1+rnd()*3)\\1\n\t\n\t\tshape={{},{}}\n\t\tbuild_plane(shape)\n\t\t\n\t\to1={{},{}}\n\t\tbuild_circ(o1)\n\t\to1=rotate_shape(o1,2,0.25)\n\t\to2={{},{}}\n\t\tbuild_circ(o2)\n\t\to2=rotate_shape(o2,2,0.25)\n\t\to2=rotate_shape(o2,3,0.25)\n\t\to3={{},{}}\n\t\tbuild_circ(o3)\n\tend\n\t\n\tif show_circ then\n\t\tdraw_shape(o1,1)\n\t\to1=rotate_shape(o1,dir,0.002)\n\t\tdraw_shape(o2,1)\n\t\to2=rotate_shape(o2,dir,0.002)\n\t\tdraw_shape(o3,1)\n\t\to3=rotate_shape(o3,dir,0.002)\n\tend\n\tdraw_shape(shape,1)\n\tshape=rotate_shape(shape,dir,0.002)\n\n\tfc+=1\nend\nflip()\ngoto ♥","tags":["pico-8","pico8"],"symbol":"OBJKT","artifactUri":"ipfs://Qme3u4pzWXDeUxNFQhC3HRxhBwf59eeJk6NchwVN6978dk","displayUri":"ipfs://QmYNvuo1CNftKeqRAR6duURj3oVnhmXLRU7sHoZNYhG9S5","thumbnailUri":"ipfs://QmNrhZHUaEqxhyLfqoq1mtHSipkWHeT31LNHb1QEbDHgnc","creators":["tz1St3n29AbYXZXV8W1BG41qYzz86J2CFAW7"],"formats":[{"uri":"ipfs://Qme3u4pzWXDeUxNFQhC3HRxhBwf59eeJk6NchwVN6978dk","mimeType":"application/x-directory"}],"decimals":0,"isBooleanAmount":false,"shouldPreferSymbol":false}