pico-8 cartridge // http://www.pico-8.com version 33 __lua__ -- arcus trigoni -- pixienop replays=0 current_scene = -2 --current_scene = 0 realscene_count = 0 final_scene = 900 -- set during running continue_scene = 0 scene_updated_this_pattern = false scene_just_entered = false rs_just_entered = false show_debug = false _demotime_start = 0 _scenetime_start = 0 function demotime() return time() - _demotime_start end function scenetime() return time() - _scenetime_start end scene_just_entered = true function demo_update() if stat(20) < 5 then if not scene_updated_this_pattern then scene_updated_this_pattern = true realscene_count += 1 rs_just_entered = true if 0 < continue_scene then continue_scene -= 1 else scene_just_entered = true current_scene += 1 if final_scene < current_scene then current_scene = 0 continue_scene = 0 -- prevent overflows realscene_count = 0 replays += 1 end _scenetime_start = time() end if current_scene == 0 then _demotime_start = time() end end else scene_updated_this_pattern = false end if btnp(4) then show_debug = not show_debug end end -->8 -- effect info -- b4s1c math function asin(y) return atan2(sqrt(1-y*y),-y) end -- tri fill from p01♥♥ function p01_trapeze_h(l,r,lt,rt,y0,y1) lt,rt=(lt-l)/(y1-y0),(rt-r)/(y1-y0) if(y0<0)l,r,y0=l-y0*lt,r-y0*rt,0 y1=min(y1,128) for y0=y0,y1 do rectfill(l,y0,r,y0) l+=lt r+=rt end end function p01_trapeze_w(t,b,tt,bt,x0,x1) tt,bt=(tt-t)/(x1-x0),(bt-b)/(x1-x0) if(x0<0)t,b,x0=t-x0*tt,b-x0*bt,0 x1=min(x1,128) for x0=x0,x1 do rectfill(x0,t,x0,b) t+=tt b+=bt end end function trifill(x0,y0,x1,y1,x2,y2,col) color(col) if(y1 y2-y0 then col=x0+(x2-x0)/(y2-y0)*(y1-y0) p01_trapeze_h(x0,x0,x1,col,y0,y1) p01_trapeze_h(x1,col,x2,x2,y1,y2) else if(x18 -- runtime function _init() -- start music music(0) end function _update() demo_update() end function _draw() -- setup local dt = demotime() local st = scenetime() for i=0,15 do pal(i,i,1) end -- et == music time et = st*1.677 --et=t()*(60/(9/(120/8))/60)-.03 fillp() -- empty first pattern~ -- this helps sync on the -- web player, since it can -- take a lil bit for that -- to start fully sc = -1 if current_scene == sc then -- do nothing srand(et) for x=1,8000 do pset(rnd(128),rnd(128),0) end end -- intro sc += 1 if current_scene == sc then if scene_just_entered then continue_scene=11 end -- music effects poke(0x5f43,0) poke(0x5f42,0) poke(0x5f41,0) poke(0x5f40,0) if continue_scene==2 then poke(0x5f42,1) poke(0x5f41,1) elseif continue_scene==8 and st<9.48 then poke(0x5f42,1) elseif flr(et)==18 then poke(0x5f41,2) elseif continue_scene==5 then if 25 < et then poke(0x5f41,1) poke(0x5f42,1) end end cls() -- bg rectangles pal(3,129,1) fillp(▥) rectfill(128,0,139-min(140,(et-16)*16),128,3) fillp() r1 = 144-min(150,(et-16)*16) rectfill(128,0,r1,128,3) pal(4,2,1) fillp(▥) rectfill(128,0,329-min(330,(et-16)*16),128,4) fillp() r2 = 334-min(340,(et-16)*16) rectfill(128,0,r2,128,4) -- rainbow bottom if continue_scene<8 then tmid = 64+sin(et/5)*12.9 for j=0,min(127,(et-16)*16),1 do mod=sin(et*.5+j*.005)*9.9+cos(et*.07+j*.01)*3.9 if 0<=mod then thiscol=(2+et*5+j*.1)%8+8 bigmod=(max(0,st-10)/5)*mod/5 k=0 for y=tmid+mod,tmid+mod*3,3+sin(et/20+.2)*2 do pset(128-j,y+bigmod*(k/3),thiscol) k+=1 end end end end -- triangle pattern etft=.23 --fine-tuning sync et+=etft colo=5 rndex=0 extra=(cos(et/20)+.5)*-4 -- lots w=30+sin(et/7)*3.9+extra -- of h=25+cos(et/7)*2.9+extra -- tweaking... xcam=-64+sin(et/15)*63.9 ycam=-64+cos(et/20)*63.9 e=min((et-4)/8,max(0,min(((et-flr(et))*7)^2,1-((et-flr(et))*1.4)^2))) for i=0,max(0,min((et-6)/2,2)) do color(colo) xi=50 yi=50 for x=-1,xi do i11=0 for y=-1,yi,2 do -- confirm we're on screen in x i41=xcam+x*w+w+w/2+srr(et,x+1,y+1,9.9)*e if 0<=i41 then -- confirm in y i52=ycam+y*h+h+h+srr(et,y+2+rndex,x,9.9)*e i62=ycam+y*h+h+h+srr(et,y+2+rndex,x+1,9.9)*e if 0<=i52 and 0<=i62 then i11=xcam+x*w+srr(et,x,y+rndex,9.9)*e i12=ycam+y*h+srr(et,y+rndex,x,9.9)*e i21=xcam+x*w+w+srr(et,x+1,y+rndex,9.9)*e i22=ycam+y*h+srr(et,y+rndex,x+1,9.9)*e i31=xcam+x*w+w/2+srr(et,x,y+1+rndex,9.9)*e i32=ycam+y*h+h+srr(et,y+1+rndex,x,9.9)*e i42=ycam+y*h+h+srr(et,y+1+rndex,x+1,9.9)*e i51=xcam+x*w+srr(et,x,y+2+rndex,9.9)*e i61=xcam+x*w+w+srr(et,x+1,y+2+rndex,9.9)*e if colo==5 and r2-1035 and fet<41) or fet== 44 or fet>45 then color(et*16+x+y*15+x) end line(i11,i12,i21,i22) line(i11,i12,i31,i32) line(i31,i32,i21,i22) line(i31,i32,i41,i42) line(i31,i32,i51,i52) line(i31,i32,i61,i62) if 1271 then print("!\f7epilepsy warning\f8!",55,120,8) end end -- tunnel load sc += 1 if current_scene == sc then for i=0,15 do pal(i,tun2loadcols[1+flr((i/4)%4)],1) end if scene_just_entered then cls() tuncx=64 tuncy=64 for y=0,127 do for x=0,127 do pset(x,y,tun2(x,y,tuncx,tuncy)) end if flr(y)%3 == 0 then flip() end end tun2_rst = st end end -- tunnel sc += 1 if current_scene == sc then if scene_just_entered then continue_scene=7 end tst=st tuncx=64+cos(tst/100)*15*min(1,tst/60) tuncy=64+sin(tst/100)*15*min(1,tst/60) et=max(0,tst-4.5) redraw_y=(tst*105)%128 for y=redraw_y,redraw_y+5 do for x=0,127 do mx=x+sin(y/60)*sin(et/60)*20 my=y+cos(x/28)*sin(et/60)*20 pset(x,y,tun2(mx,my,tuncx,tuncy)) end end txt= " code/gfx: pixienop" if continue_scene < 2 then txt="music: gruber + pixienop" end tt=tst cc=-tst*40+2 for i=1,min(et*8,#txt) do tt-=.04 print(sub(txt,i,i), 5+(i-1)*5+sin(tt/5)*10.9, 110+sin(tt)*3.9, cc) end for i=0,15 do pal(i,tun2cols[1+flr((i/2+st*20)%8)],1) end end -- transision aaa sc += 1 if current_scene == sc then if scene_just_entered then continue_scene=0 --continue_scene=1 end pal({8,10,12,136,141,1,5,14,7,137,2,3},1) --cls() -- each bg set=et\1 if set==1 then cls(3) rh=127/5 rectfill(0,rh*1,127,rh*4,8) rectfill(0,rh*2,127,rh*3,9) elseif set==3 then rh=127/6 rectfill(0,rh*0,127,rh*1,1) rectfill(0,rh*1,127,rh*2,10) rectfill(0,rh*2,127,rh*3,2) rectfill(0,rh*3,127,rh*4,12) rectfill(0,rh*4,127,rh*5,6) rectfill(0,rh*5,127,rh*6,11) end if true then -- smol flags srand(st) for i=0,2500 do circ(rnd(128),rnd(128),1,0) end srand() f="123456389:9;29579;" for j=0,200 do y=rnd(120)+sin(st/3+rnd())*8 k=rnd(6)\1*3 x=(rnd(200)-st*rnd(50))%200-3 for i=1,3 do line(x,i+y,x+3,i+y,ord(f,k+i)) end end end -- fade ins on each beat if set==1 or set==3 then -- nothing else fet=et%1 srand(et\1) for i=0,400 do circfill(rnd(128),rnd(128),5-fet*(22\rnd()),rnd(16+et)) end end end -- tentacle greets sc += 1 if current_scene == sc then if scene_just_entered then continue_scene=4 cm=0 end cet=((et-32)*8) _p={9,137,136,2,141,12,140,1,129,131,3,139,11,138,10,135} _b={6,5,0,5,6,7,6,5,0,5,6,7,6,5,0,5,6,7,6,5,0,5,6,7,6,5,0,5} for i,c in pairs(_p) do pal(i-1,c,1) if cet>0 and cet>i then pal(i-1,_b[i],1) end end if cet<0 then cls(8) else -- collapse srand(et) for i=0,300 do x=rnd(128) y=rnd(128) c1=pget(x,y-1) c2=pget(x,128-y-1) if rnd()