Skip to content

Instantly share code, notes, and snippets.

@p01
Last active March 25, 2016 22:45
Show Gist options
  • Save p01/2bac941529aef959e8c9 to your computer and use it in GitHub Desktop.
Save p01/2bac941529aef959e8c9 to your computer and use it in GitHub Desktop.
JS1k 2016: THE SECRET OF MENTAL ISLAND

Looking at the repository of @homecoded's cool entry for JS1k 2016: THE SECRET TO MENTAL ISLAND in 1024 bytes, I spotted a few bits of code that could be optimized so I did that.

The current size is 900 bytes with title and animated fluffy clouds.

Enjoy

for(_='024z),v33$22:atQon!,4GddKKKJ99@@bbJK?rocess>ect(`qq_kk^0,Z37YllX^^^WmlkmXXWVhhU5511mm☁",ff77rrrqomq__(n[parseInt("c.fiX,Text("Z:0)cc*MQh.sin(x/,1,c.globalAlpha=,R`Zxz,aaoo ii Klo@ @ Style="#K"[0|s%264],35)]*s&1) orqo ,c.f!t="pppppx serif"x+=Y)n=[35,YG1G6G9,,58,62,65,73,82,93,98101723313947658596,:Z2$,247,262,2,294,$ZY0],A=new AudioC!text,C=A.creQeScriptP>or(a.width=1zvs=ZC.c!n`A.destinQi!vC.!audiop>=functi!(l){for(b=l.outputBuer.getChannelDQa(x=0va.height=YZ214"Y0v46f".1162:740Y:054,002",x=0;x<1z;x++,s+=6.25/A.sampleRQe)R`x,$0+MQh.min(27)+4vb[x]=JV oqssss_q o VWWW^ lkjl ^ Xmsmsrs_ WU tt_qrorXXXXXXXjjUUUUfh+fi Kjo KJ@ 66enK@bb$bbfidg44cf4444cf@ jjfi@Jfk@dh?44dk00:$88ggbb@@@@@97?J UK-1),Y0);B4B"16THE SECRET OF"G8Z98)62MENTAL"G2050)ISLAND"G8096)}';G=/[-U-Z^-`>-@JKG!Q:$vz]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
// Compresses to 900 bytes ;)
b.bgColor="#36f",A=new AudioContext,C=A.createScriptProcessor(a.width=1024,s=0,1),C.connect(A.destination),C.onaudioprocess=function(b){for(a.height=480,b=b.outputBuffer.getChannelData(d=0),c.fillStyle="#9cf",c.font="116px serif",c.fillText("\u2601",7*s%1336-226,226),c.font="226px serif",c.fillText("\u2601",9*s%1336-226,226),c.font="66px serif",c.fillText("\u2601",4*s%1336-226,226),c.fillText("\u2601",6*s%1336-226,226),c.fillStyle="#003";d<1024;s+=6.25/A.sampleRate)c.fillRect(0,d,1024,d<336?1-d/336:1),c.fillRect(d,336+(b[d++]=(55*s*Math.pow(1.059463,parseInt(" qqqtsqooqqqqqqooomlommmmllllllqqqqqtsqooqqqqqqqsttttvvvvssstsqosttttssssqqqtsqosttttssssqqqtsqooqqqqqqqqqqqqomlommmmllllllllllllllllllllllllllooqqhhhhhhmljmoohhhhhhllhhmmooooovovtvttssqqllllllgghhrrrrrrrrrrrrrrrrxxttttttssttstqtttmmmmmmmmmmmmmmjjggggggeeggegccbbnqbbnn99lljjvzeeqqeellggggsnnzbbnnbbnn99lljjvzeeqqeeqqggggllxxlllleeqqaamybbnn99lleeii66iibbnq99lo77jn77jj77jneeqqggssnnnnbbnqeennllllbbnueenn99lpjjjjjjjjjjjjjjeeiillllll77lu11449999bbbb6622222222bbccggjjjjjjjjjjoonniieeeeeeeeeeebeeiillllllllllqqppllggggggggggll"[0|s%264+(d&1)*264],36)+9)&1)-.5),4,226*Math.sin(d/116)+16*Math.sin(d/16));c.fillStyle="#f6f",c.fillText("MENTAL",420,146),c.fillText("ISLAND",480,196),c.font="16px serif",c.fillText("THE SECRET OF",480,96)}
<!doctype html><style>body,canvas{display:block;margin:0;}</style></style><body id="b"><canvas id="a"></canvas><script> window.c = a.getContext('2d'); </script><script src="demo_2.js"></script></body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment