for(_="H=N='GthFMaF.cos(E*EiZ FeYbraX,t:`[i]_or(^keyL256K1+s/KJt,x,yI){onrocesste&&c.fnneif(A_.d<2+dZb.lengF','πΉt=32)+sZ+T);illText(,b:' ',s:0};;i++)'aXcadaX' peechSynFesisA_={d: liXry'*+'px cursive';'spook atY wizardf^i=0;i<MaF.random()*b.bgColorG#864';Lup=e=>No<2e.L;A=[];*8f^bG';<8*(1+i/Ki*-512`['π»','πΊ'][i&3],b:b,s:16})b+= [8|0];K+K`'π'0` U=;Ns=o=T=0;B=new AudioCxt;C=B.creaScriptP^*2,1,1C.coct(B.destinatiC.audiop=e=>{!oHNo++;A[].'π§π»'}a.widF=;a.heighh=*irHeight/irWidF;c.xtAlignGcenr';D=e.outputBuffer.getChalData(0**2{D_=E*T*(1+ET+=1/B.sampleRa)/))/16;illRect(Z),i,128,.2)}*8{bx=51y=h/+8+8b;o==1sd-=J;0o++;UGFe '+t+' tookY}512N=t[0]b=t.slice(1++s%K||(UGlevel '+(J)+'. proctY!t)'β¨'}}i==!o)[,'press any L to start'][T&1];I+6464+*8I}}}Ns,K,ohU=Us.speak(new SUtrance(U))}";G=/[-I-L^-`X-ZE-GN]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
/*
Abracadabra - Spook at the wizard library
A typing game in 1024 bytes of JavaScript with intro screen, voice over a spooky music and a cute wizard ready to save her school.
Quick! Type the name of the ghost, goblins, and ogres before they take the wizard library.
---
Thanks to my wife Joy, and daugther Vida, 6yo, for testing the game and serving as model for the cute wizard ;)
---
Mathieu 'p01' Henri - @p01 - http://www.p01.org
*/
b.bgColor = '#864';
onkeyup = e => K = o < 2 && e.key;
A = [];
// Goblins
for (i=0; i < 32 * 8; i++) {
b = '';
for (; b.length < Math.random() * 8 * (1 + i / 256);) {
b += 'abracadabra'[Math.random() * 8 | 0];
}
A[i] = { d: i * 32 - 512, t: ['π»', 'πΊ', 'πΉ', 'πΉ'][Math.random() * i & 3], b: b, s: 16 };
}
// The library
for (i = 0; i < 32; i++) {
A[i]={ d: 256 + Math.random() * 256, t: 'π', b: ' ', s: 0 };
}
// Title
A[i] = { d: 0, t: 'abracadabra', b: ' ', s: 0 };
U = 'spook at the wizard library';
K = s = o = T = 0;
B = new AudioContext;
C = B.createScriptProcessor(32 * 32 * 2, 1, 1);
C.connect(B.destination);
C.onaudioprocess = e => {
// Start ?
if (!o && K) {
K = o++;
// Our wizard
A[32].t = 'π§π»';
}
// clear
a.width = 32 * 32 ;
a.height = h = 32 * 32 * innerHeight / innerWidth;
c.textAlign = 'center';
// music (spooky theremin)
D = e.outputBuffer.getChannelData(0);
// the wooden floor
for (i = 0; i < 32 * 32 * 2; i++) {
T += 1 / B.sampleRate;
D[i] = Math.cos(32 * 32 * T * (1 + Math.cos(T) / 32)) / 16;
c.fillRect(1024 * Math.cos(i), i, 128, .2);
}
for (i = 0; i < 32 * 8; i++) {
if (A[i].b) {
x = 512 + A[i].d * Math.cos(i) + A[i].s * Math.cos(i + T);
y = h / 2 + A[i].d * Math.cos(i + 8) + A[i].s * Math.cos(i + T + 8);
t = A[i].b;
if (o == 1 && A[i].s) {
A[i].d -= 1 + i / 256;
if (A[i].d < 0) {
o++;
U = 'the ' + A[i].t + ' took the library';
}
if (A[i].d < 512 && K == t[0]) {
t = A[i].b = t.slice(1);
++s % 256 || (U = 'level ' + (1 + i / 256) + '. protect the library');
if (!t) {
A[i].t = 'β¨'
}
}
}
if (A[i].d < 32 * 32) {
if (i == 32 && !o) {
t = ['spook at the wizard library', 'press any key to start'][T & 1];
}
c.font = 32 + 'px cursive';
c.fillText(t, x, y + 64);
c.font = 64 + A[i].b.length * 8 + 'px cursive';
c.fillText(A[i].t, x, y);
}
}
}
// score
K = c.fillText(s, 256, o && h);
// speech
U = U && speechSynthesis.speak(new SpeechSynthesisUtterance(U));
}