189 lines
35 KiB
HTML
189 lines
35 KiB
HTML
<html>
|
|
<head>
|
|
|
|
|
|
|
|
|
|
<title>xx142-b2.exe</title>
|
|
<style>
|
|
@keyframes B {
|
|
0%,
|
|
50% {
|
|
opacity: 1;
|
|
}
|
|
51%,
|
|
to {
|
|
opacity: 0;
|
|
}
|
|
}
|
|
* {
|
|
user-select: none;
|
|
}
|
|
body,
|
|
html {
|
|
margin: 0;
|
|
padding: 0;
|
|
}
|
|
#M,
|
|
body {
|
|
background: #000;
|
|
}
|
|
body {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
#M {
|
|
position: absolute;
|
|
top: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
margin: auto;
|
|
width: 100vw;
|
|
height: 66.66vw;
|
|
}
|
|
@media (min-aspect-ratio: 3/2) {
|
|
#M {
|
|
width: 150vh;
|
|
height: 100vh;
|
|
}
|
|
}
|
|
#HUD {
|
|
visibility: hidden;
|
|
position: absolute;
|
|
bottom: 0;
|
|
left: 0;
|
|
right: 0;
|
|
margin: 10px;
|
|
}
|
|
#L,
|
|
#T {
|
|
font-family: monospace;
|
|
padding: 15px;
|
|
line-height: 70px;
|
|
font-size: 60px;
|
|
text-shadow: 1px 1px 3px #000;
|
|
}
|
|
#L {
|
|
float: right;
|
|
color: #afc;
|
|
transition: opacity 1.2s linear;
|
|
opacity: 0;
|
|
}
|
|
#L.a {
|
|
opacity: 1;
|
|
}
|
|
#T {
|
|
float: left;
|
|
border-radius: 10px;
|
|
width: 70px;
|
|
text-align: center;
|
|
transition: color 150ms linear, background-color 300ms linear;
|
|
background: rgba(20, 0, 40, 0.3);
|
|
border: 1px solid rgba(20, 0, 40, 0.3);
|
|
}
|
|
#T.x {
|
|
background: red;
|
|
}
|
|
#c {
|
|
padding: 0;
|
|
display: block;
|
|
visibility: hidden;
|
|
}
|
|
pre,
|
|
small {
|
|
position: absolute;
|
|
right: 0;
|
|
}
|
|
pre {
|
|
left: 0;
|
|
top: 0;
|
|
white-space: pre-wrap;
|
|
padding: 1em;
|
|
bottom: 0;
|
|
color: #8fa;
|
|
font-size: 19px;
|
|
}
|
|
#B {
|
|
display: inline-block;
|
|
background: #8fa;
|
|
animation: B 1s linear infinite;
|
|
}
|
|
.won #end {
|
|
display: block;
|
|
}
|
|
#end,
|
|
.won #hud {
|
|
display: none;
|
|
}
|
|
#intro {
|
|
overflow: hidden;
|
|
max-height: 0;
|
|
transition: max-height 1.2s linear;
|
|
}
|
|
#intro.a {
|
|
max-height: 100%;
|
|
}
|
|
.started #intro,
|
|
.started small {
|
|
display: none;
|
|
}
|
|
.started #C,
|
|
.started #HUD {
|
|
visibility: visible;
|
|
}
|
|
small {
|
|
font-family: monospace;
|
|
font-size: 13px;
|
|
bottom: 15px;
|
|
color: #040;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<main id="M">
|
|
<div id="HUD">
|
|
<div id="T"> </div>
|
|
<div id="L">-</div>
|
|
</div>
|
|
<pre id="intro">Hello, <i>xx142-b2.exe</i>
|
|
|
|
This is the year 2413,
|
|
humanity is enslaved by an alien race for more than two centuries already.
|
|
|
|
You are an AI weaponized virus built to infiltrate the alien network and deactivate all power generators and weapon systems.
|
|
|
|
The alien antivirus will detect and delete you after 13 seconds.
|
|
|
|
But remember: a file is never really deleted. Use the execution backtrace from your previous attempts to break in and destroy the main memory core.
|
|
|
|
--------------------------------------
|
|
|
|
Controls:
|
|
WASD / Arrows - movement
|
|
Backspace - kill -9 xx142-b2.exe
|
|
|
|
--------------------------------------
|
|
|
|
Press any key to continue . . . <b id="B"> </b>
|
|
</pre>
|
|
<small>Copyright (c) 2019 Ben Clark, Salvatore Previti</small>
|
|
<pre id="end">Well done <i>xx142-b2.exe</i>,
|
|
|
|
You deactivated the memory core.
|
|
|
|
All alien ships are destroyed.
|
|
You freed humanity from slavery.
|
|
|
|
|
|
|
|
How about a nice game of chess? <b id="B"> </b>
|
|
</pre>
|
|
<canvas id="c"></canvas>
|
|
</main>
|
|
|
|
<script>"use strict";((y,e,t,o,x,n,r,s,i,a,l)=>{function c(){this.A=function(y){for(var e=0;24>e;e++)this[String.fromCharCode(97+e)]=y[e]||0;.01>this.c&&(this.c=.01),.18>(y=this.b+this.c+this.e)&&(this.b*=y=.18/y,this.c*=y,this.e*=y)}}function d(y,e,t,o){let x;const n=e.x-y.x,r=e.y-y.y,s=((t.x-y.x)*n+(t.y-y.y)*r)/(r*r+n*n);if(o*o>(x=0>s||s>1?0>s?(y.x-t.x)**2+(y.y-t.y)**2:(e.x-t.x)**2+(e.y-t.y)**2:(y.x+n*s-t.x)**2+(y.y+r*s-t.y)**2)){const e=new Y(y.x+n*s,y.y+r*s),x=t.sub(e).normalize();return e.add(x.mul(o+.1))}return 0}function m(y){this.position=y.getStart(),this.movementVector=new Y(0,0),this.drawMovementVector=new Y(0,-1),this.forceMove=y=>{this.movementVector=y,this.position=this.position.add(y),this.drawMovementVector=this.movementVector.mul(-1)},this.move=e=>{const t=new Y(0,0);return e.up&&(t.y-=U),e.down&&(t.y+=U),e.left&&(t.x-=U),e.right&&(t.x+=U),(t.x||t.y)&&(this.drawMovementVector=t),this.movementVector=y.interact(this.position,N,t),this.position=this.position.add(this.movementVector),(this.movementVector.x||this.movementVector.y)&&O.move(),this.movementVector}}function p(y,e){this.position=e.getStart(),this.movementVector=iy,this._a=void 0,this.tick=t=>{if(t>y.length)return;if(t===y.length)return e.ghostRemoved(this.position,N),void(this.dead=1);const o=y[t];e.interact(this.position,N,o),this.position=this.position.add(o),this.movementVector=0===t?iy:o},this.reset=()=>{this.position=e.getStart(),this.dead=0}}function h(e){let t=y.parse(y.stringify(e));this.last=!!t.last;const o=(y,e)=>{for(let x=0;t.walls.length>x;x++)for(let n=1;t.walls[x].length>n;n++){const r=d(t.walls[x][n-1],t.walls[x][n],y,e);if(r)return o(r,e)||r}for(let x=0;t.doors.length>x;x++){if(t.doors[x].open)continue;const n=d(t.doors[x].polygon[0],t.doors[x].polygon[1],y,e);if(n)return o(n,e)||n}return 0},x=y=>{const e=t.doors.find(e=>e.name===y);e.open=!e.open},n=(y,t)=>{y.sub(new Y(e.end.x,e.end.y)).len()<t+_&&(this.completed=1)};this.ghostRemoved=(y,e)=>{for(const o of t.switches)if(y.sub(new Y(o.x,o.y)).len()<e+_&&("single"!==o.type&&o.pressed--,0===o.pressed&&"momentary"===o.type))for(const y of o.targets)x(y)},this.getStart=()=>new Y(e.start.x,e.start.y),this.reset=()=>{t=y.parse(y.stringify(e))},this.interact=(y,e,r)=>{let s=y.add(r);const i=o(s,e);return((y,e,o)=>{if(y.x!==e.x||y.y!==e.y)for(const n of t.switches){const t=new Y(n.x,n.y),r=y.sub(t).len()<o+_,s=e.sub(t).len()<o+_;if(!r&&s){if(0===n.pressed){for(const y of n.targets)x(y);O.switchDown()}n.pressed++}if(r&&!s&&"single"!==n.type){if(0>=n.pressed)continue;n.pressed--}if(r&&!s&&"momentary"===n.type&&0===n.pressed)for(const y of n.targets)x(y);r&&!s&&0===n.pressed&&O.switchUp()}})(y,s=i||s,e),n(s,e),i?i.sub(y):r},this.getLevel=()=>t}const{sin:u,cos:f,tan:g,hypot:v,atan2:w,sqrt:b,abs:S,round:E,PI:A}=e,L=2*A,T=(y,e,t)=>[y/255,e/255,t/255],R=y=>y>0?y>1?1:y:0,C=(y,e,t)=>y*(1-(t=R(t)))+e*t,N=10,_=15,U=5,P=.01;var F=new function(){var y,o,x,n,r,s,i,a,l,d,m,p;this.z=new c,this.reset=function(){var y=this.z;n=100/(y.f*y.f+.001),r=100/(y.g*y.g+.001),s=1-.01*y.h*y.h*y.h,i=1e-6*-y.i*y.i*y.i,y.a||(m=.5-y.n/2,p=5e-5*-y.o),a=1+y.l*y.l*(y.l>0?-.9:10),l=0,d=1==y.m?0:2e4*(1-y.m)*(1-y.m)+32},this.C=function(){this.reset();var e=this.z;return 3*(((y=1e5*e.b*e.b)+(o=1e5*e.c*e.c)+(x=1e5*e.e*e.e+12))/3|0)},this.B=function(c,h){var u,f,g,v,w,b,S,E,A,L,T,R,C,N,_,U,P,F,I,D,B=this.z,V=1!=B.s||B.v,z=.1*B.v*B.v,k=1+3e-4*B.w,M=.1*B.s*B.s*B.s,G=1+1e-4*B.t,H=1!=B.s,O=B.x*B.x,Y=B.g,q=B.q||B.r,K=.2*B.r*B.r*B.r,j=B.q*B.q*(0>B.q?-1020:1020),W=B.p?32+(2e4*(1-B.p)*(1-B.p)|0):0,X=B.d,$=B.j/2,J=.01*B.k*B.k,Q=B.a,Z=y,yy=1/y,ey=1/o,ty=1/x;for((B=5/(1+20*B.u*B.u)*(.01+M))>.8&&(B=.8),B=1-B,u=0,f=0,g=0,v=0,w=0,b=0,E=0,L=0,R=0,N=0,U=0,P=t(1024),F=t(32),I=P.length;I--;)P[I]=0;for(I=F.length;I--;)F[I]=2*e.random()-1;for(I=0;h>I;I++){if(u)return I;if(W&&++N>=W&&(N=0,this.reset()),d&&++l>=d&&(d=0,n*=a),(n*=s+=i)>r&&(n=r,Y>0&&(u=1)),A=n,$>0&&(A*=1+e.sin(U+=J)*$),8>(A|=0)&&(A=8),Q||(0>(m+=p)?m=0:m>.5&&(m=.5)),++g>Z)switch(g=0,++f){case 1:Z=o;break;case 2:Z=x}switch(f){case 0:v=g*yy;break;case 1:v=1+2*(1-g*ey)*X;break;case 2:v=1-g*ty;break;case 3:v=0,u=1}for(q&&(0>(T=0|(j+=K))?T=-T:T>1023&&(T=1023)),V&&k&&(1e-5>(z*=k)?z=1e-5:z>.1&&(z=.1)),_=0,D=8;D--;){if(++L>=A&&(L%=A,3==Q))for(S=F.length;S--;)F[S]=2*e.random()-1;switch(Q){case 0:C=m>L/A?.5:-.5;break;case 1:C=1-L/A*2;break;case 2:C=.225*((0>(C=1.27323954*(C=6.28318531*((C=L/A)>.5?C-1:C))+.405284735*C*C*(0>C?1:-1))?-1:1)*C*C-C)+C;break;case 3:C=F[e.abs(32*L/A|0)]}V&&(S=E,0>(M*=G)?M=0:M>.1&&(M=.1),H?(b+=(C-E)*M,b*=B):(E=C,b=0),w+=(E+=b)-S,C=w*=1-z),q&&(P[R%1024]=C,C+=P[(R-T+1024)%1024],R++),_+=C}c[I]=1>(_*=.125*v*O)?_>-1?32767*_|0:-32768:32767}return h}};o.jsfxr=y=>{var e,t,o,n,r;for(F.z.A(y),e=F.C(),y=new Uint8Array(4*((e+1)/2|0)+44),e=2*F.B(new x(y.buffer,44),e),(t=new Uint32Array(y.buffer,0,44))[0]=1179011410,t[1]=e+36,t[2]=1163280727,t[3]=544501094,t[4]=16,t[5]=65537,t[6]=44100,t[7]=88200,t[8]=1048578,t[9]=1635017060,t[10]=e,e+=44,t=0,o="data:audio/wav;base64,",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";e>t;t+=3)o+=n[(r=y[t]<<16|y[t+1]<<8|y[t+2])>>18]+n[r>>12&63]+n[r>>6&63]+n[63&r];return o};const I=[{id:0,walls:[[{x:384,y:704},{x:384,y:768},{x:416,y:800},{x:480,y:800},{x:512,y:768},{x:512,y:704},{x:480,y:672},{x:480,y:576},{x:480,y:480},{x:480,y:384},{x:480,y:288},{x:576,y:288},{x:576,y:160},{x:320,y:160},{x:320,y:288},{x:416,y:288},{x:416,y:384},{x:416,y:480},{x:416,y:576},{x:416,y:672},{x:384,y:704}]],polys:[[{x:480,y:288},{x:576,y:288},{x:576,y:160},{x:320,y:160},{x:320,y:288},{x:416,y:288}],[{x:384,y:768},{x:416,y:800},{x:480,y:800},{x:512,y:768},{x:512,y:704},{x:480,y:672},{x:416,y:672},{x:384,y:704}],[{x:416,y:384},{x:416,y:480},{x:416,y:576},{x:416,y:672},{x:480,y:672},{x:480,y:576},{x:480,y:480},{x:480,y:384},{x:480,y:288},{x:416,y:288}]],doors:[{name:"door1",polygon:[{x:416,y:288},{x:480,y:288},{x:480,y:297},{x:416,y:297},{x:416,y:288}],open:0}],switches:[{uid:0,x:448,y:480,targets:["door1"],type:"momentary",pressed:0}],start:{x:448,y:736},end:{x:448,y:224}},{id:1,walls:[[{x:288,y:928},{x:320,y:960},{x:384,y:960},{x:416,y:928},{x:416,y:928},{x:512,y:928},{x:544,y:896},{x:544,y:736},{x:448,y:640},{x:448,y:608},{x:512,y:544},{x:640,y:544},{x:640,y:576},{x:576,y:608},{x:576,y:704},{x:704,y:768},{x:832,y:704},{x:832,y:608},{x:768,y:576},{x:768,y:512},{x:704,y:448},{x:512,y:448},{x:512,y:352},{x:512,y:352},{x:544,y:352},{x:544,y:224},{x:416,y:224},{x:416,y:352},{x:448,y:352},{x:448,y:448},{x:320,y:576},{x:320,y:672},{x:448,y:800},{x:448,y:864},{x:416,y:864},{x:384,y:832},{x:320,y:832},{x:288,y:864},{x:288,y:928}]],polys:[[{x:512,y:352},{x:544,y:352},{x:544,y:224},{x:416,y:224},{x:416,y:352},{x:448,y:352}],[{x:640,y:576},{x:576,y:608},{x:576,y:704},{x:704,y:768},{x:832,y:704},{x:832,y:608},{x:768,y:576}],[{x:416,y:864},{x:384,y:832},{x:320,y:832},{x:288,y:864},{x:288,y:928},{x:320,y:960},{x:384,y:960},{x:416,y:928}],[{x:448,y:864},{x:416,y:864},{x:416,y:928},{x:512,y:928}],[{x:768,y:512},{x:704,y:448},{x:512,y:448},{x:512,y:544},{x:640,y:544}],[{x:640,y:544},{x:640,y:576},{x:768,y:576},{x:768,y:512}],[{x:320,y:672},{x:448,y:800},{x:448,y:640},{x:448,y:608},{x:448,y:448},{x:320,y:576}],[{x:512,y:352},{x:448,y:352},{x:448,y:448},{x:448,y:608},{x:512,y:544},{x:512,y:448}],[{x:544,y:896},{x:544,y:736},{x:448,y:640},{x:448,y:800},{x:448,y:864},{x:512,y:928}]],doors:[{name:"door2",polygon:[{x:448,y:352},{x:512,y:352},{x:512,y:359},{x:448,y:359},{x:448,y:352}],open:0},{name:"door1",polygon:[{x:448,y:416},{x:512,y:416},{x:448,y:416}],open:0}],switches:[{uid:1,x:768,y:672,targets:["door1"],type:"momentary",pressed:0},{uid:2,x:640,y:672,targets:["door2"],type:"momentary",pressed:0}],start:{x:352,y:896},end:{x:480,y:288}},{id:2,walls:[[{x:416,y:832},{x:480,y:832},{x:480,y:672},{x:576,y:672},{x:576,y:608},{x:480,y:608},{x:480,y:320},{x:416,y:320},{x:416,y:608},{x:320,y:608},{x:320,y:672},{x:416,y:672},{x:416,y:832}],[{x:576,y:768},{x:576,y:704},{x:512,y:704},{x:512,y:768},{x:576,y:768}],[{x:384,y:768},{x:384,y:704},{x:320,y:704},{x:320,y:768},{x:384,y:768}],[{x:384,y:576},{x:384,y:512},{x:320,y:512},{x:320,y:576},{x:384,y:576}],[{x:576,y:576},{x:576,y:512},{x:512,y:512},{x:512,y:576},{x:576,y:576}]],polys:[[{x:416,y:608},{x:320,y:608},{x:320,y:672},{x:416,y:672}],[{x:480,y:672},{x:576,y:672},{x:576,y:608},{x:480,y:608}],[{x:480,y:832},{x:480,y:672},{x:480,y:608},{x:480,y:320},{x:416,y:320},{x:416,y:608},{x:416,y:672},{x:416,y:832}],[{x:576,y:704},{x:512,y:704},{x:512,y:768},{x:576,y:768}],[{x:384,y:704},{x:320,y:704},{x:320,y:768},{x:384,y:768}],[{x:384,y:512},{x:320,y:512},{x:320,y:576},{x:384,y:576}],[{x:576,y:512},{x:512,y:512},{x:512,y:576},{x:576,y:576}]],doors:[{name:"door1",polygon:[{x:416,y:608},{x:480,y:608},{x:416,y:608}],open:0},{name:"door2",polygon:[{x:416,y:544},{x:480,y:544},{x:416,y:544}],open:0},{name:"door3",polygon:[{x:416,y:480},{x:480,y:480},{x:416,y:480}],open:0},{name:"door4",polygon:[{x:416,y:416},{x:480,y:416},{x:416,y:416}],open:0}],switches:[{uid:3,x:352,y:640,targets:["door1","door3"],type:"momentary",pressed:0},{uid:4,x:416,y:640,targets:["door3","door4"],type:"momentary",pressed:0},{uid:5,x:480,y:640,targets:["door1","door2"],type:"momentary",pressed:0},{uid:6,x:544,y:640,targets:["door2","door3"],type:"momentary",pressed:0},{uid:7,x:448,y:448,targets:["door4"],type:"single",pressed:0}],start:{x:448,y:800},end:{x:448,y:352}},{id:3,walls:[[{x:448,y:960},{x:512,y:960},{x:512,y:864},{x:512,y:736},{x:640,y:736},{x:800,y:736},{x:800,y:672},{x:640,y:672},{x:512,y:672},{x:512,y:544},{x:512,y:352},{x:576,y:352},{x:640,y:288},{x:576,y:224},{x:384,y:224},{x:320,y:288},{x:384,y:352},{x:448,y:352},{x:448,y:544},{x:448,y:672},{x:320,y:672},{x:192,y:672},{x:192,y:640},{x:224,y:608},{x:352,y:608},{x:416,y:544},{x:416,y:448},{x:352,y:384},{x:192,y:384},{x:96,y:480},{x:96,y:704},{x:128,y:736},{x:320,y:736},{x:448,y:736},{x:448,y:864},{x:448,y:960}]],polys:[[{x:512,y:352},{x:576,y:352},{x:640,y:288},{x:576,y:224},{x:384,y:224},{x:320,y:288},{x:384,y:352},{x:448,y:352}],[{x:512,y:672},{x:512,y:544},{x:512,y:352},{x:448,y:352},{x:448,y:544},{x:448,y:672}],[{x:448,y:736},{x:448,y:864},{x:448,y:960},{x:512,y:960},{x:512,y:864},{x:512,y:736}],[{x:192,y:384},{x:96,y:480},{x:96,y:704},{x:192,y:672},{x:192,y:640}],[{x:352,y:384},{x:192,y:384},{x:192,y:640},{x:224,y:608}],[{x:224,y:608},{x:352,y:608},{x:416,y:544},{x:416,y:448},{x:352,y:384}],[{x:640,y:736},{x:800,y:736},{x:800,y:672},{x:640,y:672},{x:512,y:672},{x:448,y:672},{x:320,y:672},{x:192,y:672},{x:96,y:704},{x:128,y:736},{x:320,y:736},{x:448,y:736},{x:512,y:736}]],doors:[{name:"door2",polygon:[{x:448,y:352},{x:512,y:352},{x:512,y:359},{x:448,y:359},{x:448,y:352}],open:0},{name:"door1",polygon:[{x:448,y:672},{x:448,y:736},{x:440,y:736},{x:440,y:672},{x:448,y:672}],open:0}],switches:[{uid:8,x:352,y:512,targets:["door2"],type:"momentary",pressed:0},{uid:9,x:769,y:702,targets:["door1"],type:"toggle",pressed:0}],start:{x:480,y:928},end:{x:480,y:288}},{id:4,walls:[[{x:416,y:704},{x:480,y:704},{x:480,y:320},{x:416,y:320},{x:416,y:704}]],polys:[[{x:480,y:704},{x:480,y:320},{x:416,y:320},{x:416,y:704}]],doors:[{name:"door2",polygon:[{x:416,y:544},{x:480,y:544},{x:416,y:544}],open:0},{name:"door3",polygon:[{x:416,y:480},{x:480,y:480},{x:416,y:480}],open:0},{name:"door4",polygon:[{x:416,y:416},{x:480,y:416},{x:416,y:416}],open:1}],switches:[{uid:10,x:448,y:448,targets:["door3","door4"],type:"single",pressed:0},{uid:11,x:448,y:512,targets:["door4"],type:"momentary",pressed:0},{uid:12,x:448,y:576,targets:["door2","door3"],type:"momentary",pressed:0}],start:{x:448,y:672},end:{x:448,y:384}},{id:5,walls:[[{x:224,y:160},{x:224,y:0},{x:160,y:0},{x:160,y:160},{x:96,y:160},{x:64,y:96},{x:0,y:96},{x:0,y:288},{x:64,y:288},{x:96,y:224},{x:160,y:224},{x:160,y:288},{x:128,y:288},{x:160,y:384},{x:224,y:384},{x:256,y:288},{x:224,y:288},{x:224,y:224},{x:288,y:224},{x:320,y:288},{x:384,y:288},{x:384,y:96},{x:320,y:96},{x:288,y:160},{x:224,y:160}]],polys:[[{x:288,y:224},{x:320,y:288},{x:384,y:288},{x:384,y:96},{x:320,y:96},{x:288,y:160}],[{x:160,y:288},{x:128,y:288},{x:160,y:384},{x:224,y:384},{x:256,y:288},{x:224,y:288}],[{x:160,y:224},{x:160,y:288},{x:224,y:288},{x:224,y:224}],[{x:96,y:160},{x:64,y:96},{x:0,y:96},{x:0,y:288},{x:64,y:288},{x:96,y:224}],[{x:224,y:160},{x:224,y:0},{x:160,y:0},{x:160,y:160}],[{x:160,y:160},{x:96,y:160},{x:96,y:224},{x:160,y:224},{x:224,y:224},{x:288,y:224},{x:288,y:160},{x:224,y:160}]],doors:[{name:"door2",polygon:[{x:160,y:224},{x:224,y:224},{x:160,y:224}],open:0},{name:"door1",polygon:[{x:160,y:160},{x:224,y:160},{x:160,y:160}],open:0},{name:"door3",polygon:[{x:160,y:160},{x:160,y:224},{x:160,y:160}],open:0},{name:"door4",polygon:[{x:224,y:160},{x:224,y:224},{x:224,y:160}],open:1}],switches:[{uid:13,x:352,y:128,targets:["door4"],type:"momentary",pressed:0},{uid:14,x:352,y:256,targets:["door4","door3"],type:"momentary",pressed:0},{uid:15,x:32,y:128,targets:["door3","door2"],type:"momentary",pressed:0},{uid:16,x:32,y:256,targets:["door4","door3"],type:"momentary",pressed:0},{uid:17,x:192,y:352,targets:["door2","door1"],type:"momentary",pressed:0}],start:{x:192,y:192},end:{x:192,y:32}},{id:6,walls:[[{x:416,y:960},{x:480,y:960},{x:480,y:288},{x:512,y:288},{x:576,y:352},{x:576,y:576},{x:480,y:672},{x:480,y:864},{x:640,y:736},{x:640,y:192},{x:480,y:192},{x:480,y:32},{x:128,y:32},{x:128,y:960},{x:416,y:960},{x:416,y:864},{x:256,y:736},{x:256,y:192},{x:416,y:192},{x:256,y:192},{x:256,y:736},{x:416,y:864},{x:416,y:672},{x:320,y:576},{x:320,y:352},{x:384,y:288},{x:416,y:288},{x:416,y:960}],[{x:576,y:352},{x:512,y:288},{x:480,y:288},{x:480,y:672},{x:576,y:576},{x:576,y:352}],[{x:640,y:192},{x:640,y:32},{x:480,y:32},{x:480,y:192},{x:640,y:192}],[{x:384,y:288},{x:320,y:352},{x:320,y:576},{x:416,y:672},{x:416,y:288},{x:384,y:288}],[{x:640,y:736},{x:480,y:864},{x:480,y:960},{x:640,y:960},{x:640,y:736}],[{x:704,y:32},{x:640,y:32},{x:640,y:960},{x:704,y:960},{x:704,y:32}]],polys:[[{x:256,y:736},{x:416,y:864},{x:416,y:672},{x:320,y:576}],[{x:256,y:192},{x:256,y:736},{x:320,y:576},{x:320,y:352}],[{x:416,y:192},{x:256,y:192},{x:320,y:352},{x:384,y:288}],[{x:416,y:192},{x:384,y:288},{x:416,y:288}],[{x:128,y:960},{x:416,y:960},{x:416,y:864},{x:256,y:736}],[{x:128,y:32},{x:128,y:960},{x:256,y:736},{x:256,y:192}],[{x:480,y:192},{x:480,y:32},{x:128,y:32},{x:256,y:192},{x:416,y:192}],[{x:480,y:192},{x:416,y:192},{x:416,y:288},{x:416,y:960},{x:480,y:960},{x:480,y:288}],[{x:640,y:192},{x:480,y:192},{x:480,y:288},{x:512,y:288}],[{x:640,y:192},{x:512,y:288},{x:576,y:352}],[{x:640,y:736},{x:640,y:192},{x:576,y:352},{x:576,y:576}],[{x:576,y:576},{x:480,y:672},{x:480,y:864},{x:640,y:736}],[{x:512,y:288},{x:480,y:288},{x:480,y:672},{x:576,y:576},{x:576,y:352}],[{x:640,y:32},{x:480,y:32},{x:480,y:192},{x:640,y:192}],[{x:320,y:352},{x:320,y:576},{x:416,y:672},{x:416,y:288},{x:384,y:288}],[{x:640,y:736},{x:480,y:864},{x:480,y:960},{x:640,y:960},{x:640,y:736}],[{x:704,y:32},{x:640,y:32},{x:640,y:960},{x:704,y:960},{x:704,y:32}]],doors:[{name:"door2",polygon:[{x:416,y:416},{x:480,y:416},{x:416,y:416}],open:0},{name:"door1",polygon:[{x:416,y:512},{x:480,y:512},{x:416,y:512}],open:0},{name:"door3",polygon:[{x:576,y:576},{x:640,y:576},{x:576,y:576}],open:0}],switches:[{uid:18,x:448,y:480,targets:["door2"],type:"momentary",pressed:0},{uid:19,x:320,y:703,targets:["door3"],type:"momentary",pressed:0},{uid:20,x:448,y:576,targets:["door1"],type:"momentary",pressed:0}],start:{x:448,y:736},end:{x:576,y:703}},{id:7,walls:[[{x:256,y:128},{x:96,y:480},{x:256,y:832},{x:736,y:832},{x:896,y:480},{x:736,y:128},{x:256,y:128}],[{x:338,y:701},{x:281,y:797},{x:338,y:701}],[{x:657,y:699},{x:711,y:796},{x:657,y:699}],[{x:448,y:416},{x:416,y:480},{x:448,y:544},{x:544,y:544},{x:576,y:480},{x:544,y:416},{x:576,y:480},{x:544,y:544},{x:448,y:544},{x:416,y:480},{x:448,y:416}],[{x:128,y:480},{x:224,y:480},{x:128,y:480}],[{x:768,y:480},{x:864,y:480},{x:768,y:480}],[{x:654,y:258},{x:713,y:163},{x:654,y:258}],[{x:277,y:163},{x:334,y:257},{x:277,y:163}]],polys:[[{x:96,y:480},{x:256,y:832},{x:736,y:832},{x:896,y:480},{x:736,y:128},{x:256,y:128}],[{x:338,y:701},{x:281,y:797},{x:338,y:701}],[{x:657,y:699},{x:711,y:796},{x:657,y:699}],[{x:448,y:416},{x:416,y:480},{x:448,y:544},{x:544,y:544},{x:576,y:480},{x:544,y:416},{x:576,y:480},{x:544,y:544},{x:448,y:544},{x:416,y:480},{x:448,y:416}],[{x:128,y:480},{x:224,y:480},{x:128,y:480}],[{x:768,y:480},{x:864,y:480},{x:768,y:480}],[{x:654,y:258},{x:713,y:163},{x:654,y:258}],[{x:277,y:163},{x:334,y:257},{x:277,y:163}]],doors:[{name:"l1door",polygon:[{x:352,y:672},{x:640,y:672},{x:352,y:672}],open:0},{name:"l1door_open",polygon:[{x:352,y:672},{x:256,y:480},{x:352,y:672}],open:0},{name:"l1door",polygon:[{x:736,y:480},{x:640,y:672},{x:736,y:480}],open:0},{name:"l1door",polygon:[{x:736,y:480},{x:640,y:288},{x:736,y:480}],open:0},{name:"l1door",polygon:[{x:352,y:288},{x:640,y:288},{x:352,y:288}],open:0},{name:"l1door",polygon:[{x:352,y:288},{x:256,y:480},{x:352,y:288}],open:0},{name:"l2door_open",polygon:[{x:416,y:352},{x:576,y:352},{x:416,y:352}],open:0},{name:"l2door",polygon:[{x:640,y:480},{x:576,y:352},{x:640,y:480}],open:0},{name:"l2door",polygon:[{x:640,y:480},{x:576,y:608},{x:640,y:480}],open:0},{name:"l2door",polygon:[{x:416,y:608},{x:576,y:608},{x:416,y:608}],open:0},{name:"l2door",polygon:[{x:416,y:608},{x:352,y:480},{x:416,y:608}],open:0},{name:"l2door",polygon:[{x:416,y:352},{x:352,y:480},{x:416,y:352}],open:0}],switches:[{uid:21,x:494.074,y:639.013,targets:["l2door_open"],type:"momentary",pressed:0},{uid:22,x:495.676,y:254.644,targets:["l1door_open"],type:"momentary",pressed:0}],start:{x:496,y:720},end:{x:496,y:478},last:1}],D=jsfxr,B=[];B[0]=new n(D([2,.1835,.3165,,.466,.172,,-.0109,1,.261,.228,.7,.428,.2505,-.002,1,-.2329,.1,.968,-3e-4,.413,.1634,-.01,.5])),B[0].volume=.7,B[1]=B[0].cloneNode(),B[1].volume=.7,B[2]=B[0].cloneNode(),B[2].volume=.7;const V=new n(D([2,.0102,.066,.539,.1037,.2835,,-.189,-.322,,,.8999,,,,,,,1,,,,,.5])),z=new n(D([2,.0102,.066,.539,.1037,.239,,-.189,-.322,,,.8999,,,,,,,1,,,,,.5]));V.volume=.5,z.volume=.5;const k=new n(D([1,,.3266,,.2971,.2594,,.2258,,,,,,,,.7482,,,1,,,,,.5]));k.volume=.3;const M=new n(D([0,,.261,,.8055,.4874,,.1788,,,,,,.2292,,.4519,,,1,,,,,.5]));M.volume=.3;let G=0,H=0;const O={move(){G||(G=1,++H==B.length&&(H=0),B[H].play(),r(()=>{G=0},400))},switchDown(){V.play()},switchUp(){z.play()},death(){k.play()},win(){M.play()}};class Y{constructor(y,e){this.x=y,this.y=e}add(y){return new Y(this.x+y.x,this.y+y.y)}sub(y){return new Y(this.x-y.x,this.y-y.y)}len(){const{x:y,y:e}=this;return b(y*y+e*e)}mul(y){return new Y(this.x*y,this.y*y)}normal(){const y=this.len();return new Y(-this.y/y,this.x/y)}normalize(){const y=this.len();return new Y(this.x/y,this.y/y)}copy(){return new Y(this.x,this.y)}}const q={add:(y,e)=>[y[0]+e[0],y[1]+e[1],y[2]+e[2]],sub:(y,e)=>[y[0]-e[0],y[1]-e[1],y[2]-e[2]],dot:(y,e)=>y[0]*e[0]+y[1]*e[1]+y[2]*e[2],cross:(y,e)=>[y[1]*e[2]-y[2]*e[1],y[2]*e[0]-y[0]*e[2],y[0]*e[1]-y[1]*e[0]],len:y=>b(y[0]*y[0]+y[1]*y[1]+y[2]*y[2]),normalize(y){const e=q.len(y);return[y[0]/e,y[1]/e,y[2]/e]},mul:(y,e)=>[y[0]*e,y[1]*e,y[2]*e]},K=new s(16);K[0]=1,K[5]=1,K[10]=1,K[15]=1;const j=(y,e)=>{const t=u(e),o=f(e),x=y[4],n=y[5],r=y[6],s=y[7],i=y[8],a=y[9],l=y[10],c=y[11];y[4]=x*o+i*t,y[5]=n*o+a*t,y[6]=r*o+l*t,y[7]=s*o+c*t,y[8]=i*o-x*t,y[9]=a*o-n*t,y[10]=l*o-r*t,y[11]=c*o-s*t},W=(y,e)=>{const t=u(e),o=f(e),x=y[0],n=y[1],r=y[2],s=y[3],i=y[8],a=y[9],l=y[10],c=y[11];y[0]=x*o-i*t,y[1]=n*o-a*t,y[2]=r*o-l*t,y[3]=s*o-c*t,y[8]=x*t+i*o,y[9]=n*t+a*o,y[10]=r*t+l*o,y[11]=s*t+c*o},X=(y,e)=>{const t=u(e),o=f(e),x=y[0],n=y[1],r=y[2],s=y[3],i=y[4],a=y[5],l=y[6],c=y[7];y[0]=x*o+i*t,y[1]=n*o+a*t,y[2]=r*o+l*t,y[3]=s*o+c*t,y[4]=i*o-x*t,y[5]=a*o-n*t,y[6]=l*o-r*t,y[7]=c*o-s*t},$=(y,e,t,o)=>{y[12]=y[0]*e+y[4]*t+y[8]*o+y[12],y[13]=y[1]*e+y[5]*t+y[9]*o+y[13],y[14]=y[2]*e+y[6]*t+y[10]*o+y[14],y[15]=y[3]*e+y[7]*t+y[11]*o+y[15]},J=T(0,50,100),Q=T(0,80,230),Z=T(0,100,255),yy=T(20,60,170),ey=T(255,0,0),ty=T(100,100,100);let oy,xy,ny,ry;const sy={player:{},ghost:{},pad:{},core:{}};(()=>{const e=[],t=[],o=[],n=[],r=[0,1,0],a=new i,l=(x,n,s=r)=>{const i=y.stringify([x,n,s]);let l=a.get(i);return void 0===l&&(a.set(i,l=a.size),e.push(-x[0]*P,x[1]*P,x[2]*P),o.push(...n),t.push(...s)),l},c=(y,e,t,o)=>{const x=q.sub(e,y),r=q.sub(t,y),s=q.cross(x,r);n.push(l(y,o,s),l(e,o,s),l(t,o,s))},d=(y,e,t,o,x)=>{c(y,e,o,x),c(e,t,o,x)},m=(y,e,t,o,x,n,r,s=0)=>{const i=[];for(let o=0;6>o;++o){const x=s+o/6*L;i.push([u(x)*t+y,f(x)*t+e])}((y,e,t,o,x=o)=>{((y,e,t)=>{const o=y[0];let x=y[1];for(let n,r=2;y.length>r;++r,x=n)c([o[0],e,o[1]],[x[0],e,x[1]],[(n=y[r])[0],e,n[1]],t)})(y,e,o);let n=y[0];for(let o,r=1;y.length>=r;++r,n=o)d([n[0],t,n[1]],[(o=y[r%6])[0],t,o[1]],[o[0],e,o[1]],[n[0],e,n[1]],x)})(i,o,x,n,r)},p=(y,e,t,o)=>{d(...e,t),d(y[0],y[1],e[1],e[0],o||t),d(y[0],e[0],e[3],y[3],o||t),d(y[3],e[3],e[2],y[2],o||t),d(y[2],e[2],e[1],y[1],o||t)};for(const y of I){y.ibStart=n.length;const e=y.walls;for(const y of e)for(let e=0;y.length>e;++e){const t=y[e],o=y[(e+1)%y.length],x=new Y(t.x,t.y),n=new Y(o.x,o.y),r=v(n.x-x.x,n.y-x.y);if(0===r)continue;const s=-(x.y-n.y)/r,i=(x.x-n.x)/r,a=5,l=-10,c=1,h=1e3;d([x.x,h,x.y],[n.x,h,n.y],[n.x,c,n.y],[x.x,c,x.y],J);const u=new Y(s,i).mul(a/2),f=[x.sub(u),n.sub(u),n.add(u),x.add(u)];p([[f[0].x,c,f[0].y],[f[1].x,c,f[1].y],[f[2].x,c,f[2].y],[f[3].x,c,f[3].y]],[[f[0].x,l,f[0].y],[f[1].x,l,f[1].y],[f[2].x,l,f[2].y],[f[3].x,l,f[3].y]],Z),m(x.x,x.y,6,l-2,h,Q)}for(const e of y.polys){const y=e[0];let t=e[1];for(let o=2;e.length>o;++o){const x=e[o];c([y.x,1,y.y],[t.x,1,t.y],[x.x,1,x.y],yy),t=x}}for(const e of y.doors)for(let y=0,t=e.polygon;2>y;++y)m(t[y].x,t[y].y,5,-22,1,ty);y.ibCount=n.length-y.ibStart;for(const e of y.doors){const y=e.polygon,t=new Y(y[0].x,y[0].y),o=new Y(y[1].x,y[1].y),x=o.sub(t).normal().mul(1),r=[t.sub(x),o.sub(x),o.add(x),t.add(x)];e.ibStart=n.length;for(let y=0;2>y;++y){const e=-4-10*y,t=-6-10*y;p([[r[0].x,e,r[0].y],[r[1].x,e,r[1].y],[r[2].x,e,r[2].y],[r[3].x,e,r[3].y]],[[r[0].x,t,r[0].y],[r[1].x,t,r[1].y],[r[2].x,t,r[2].y],[r[3].x,t,r[3].y]],ey)}e.ibCount=n.length-e.ibStart}}sy.player.ibStart=n.length,c([0,-1,-10],[0,-3,5],[7,-1,5],[.8,0,.8]),c([0,-1,-10],[-7,-1,5],[0,-3,5],[.6,0,.6]),c([0,-3,5],[-7,-1,5],[0,-1,10],[.5,0,.4]),c([0,-3,5],[0,-1,10],[7,-1,5],[.7,0,.4]),sy.player.ibCount=n.length-sy.player.ibStart,sy.ghost.ibStart=n.length,c([0,-1,-10],[0,-1,5],[7,-1,5],[.2,0,.2]),c([0,-1,-10],[-7,-1,5],[0,-1,5],[.15,0,.15]),c([0,-1,5],[-7,-1,5],[0,-1,10],[.11,0,.1]),c([0,-1,5],[0,-1,10],[7,-1,5],[.19,0,.1]),sy.ghost.ibCount=n.length-sy.ghost.ibStart,sy.pad.ibStart=n.length,m(0,0,20,-4,.1,[1,1,1],[.5,.5,.5]),sy.pad.ibCount=n.length-sy.pad.ibStart,sy.core.ibStart=n.length;for(let y=0;25>y;y+=2)m(0,0,20,-4-5*y,.1-5*y+y/5,[1,1,1],[.5,.5,.5],y);sy.core.ibCount=n.length-sy.core.ibStart,oy=new s(e),xy=new s(t),ny=new s(o),ry=new x(n)})();const iy=new Y(0,-1),ay=new function(y){function t(y=_){y.set(K),j(y,b),W(y,T),X(y,-A),$(y,N[0]*P,N[1]*P,N[2]*P)}const x=y.getContext("webgl"),n=a.getElementById("M"),r=a.getElementById("T"),l=(y,e=x.ARRAY_BUFFER)=>{const t=x.createBuffer();return x.bindBuffer(e,t),x.bufferData(e,y,x.STATIC_DRAW),t},c=l(oy),d=l(xy),m=l(ny),p=l(ry,x.ELEMENT_ARRAY_BUFFER);let h=0,u=0;const v=()=>{const e=n.clientWidth,t=n.clientHeight;h===e&&u===t||(y.width=h=e,y.height=u=t,(()=>{const y=h/u,e=g(20*A/180);U[0]=.5/e,U[5]=.5*y/e,U[10]=-100.1/99.9,U[11]=-1,U[14]=-20/99.9})())};let b=1,T=0,N=null;const _=new s(16),U=new s(16),F=new s(3);v(),o.addEventListener("resize",v);const I=(y,e,t)=>{const o=x.createShader(t);x.shaderSource(o,e),x.compileShader(o),x.getShaderParameter(o,x.COMPILE_STATUS),x.attachShader(y,o)},D=x.createProgram();if(I(D,"\nuniform mat4 Pmatrix;\nuniform mat4 Vmatrix;\nuniform highp vec3 playerLightPosition;\nuniform vec3 inTranslation;\nuniform vec3 inAmbientColor;\nuniform highp float inFade;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec3 color;\n\nvarying highp vec3 vColor;\nvarying highp vec3 vNormal;\nvarying highp vec3 vPosition;\n\nvoid main(void) {\n vec3 wp = position + inTranslation;\n gl_Position = Pmatrix * Vmatrix * vec4(wp + vec3(0., 1.-inFade, 0.), 1.);\n vPosition = wp;\n vNormal = normal;\n vColor = color * inAmbientColor * inFade;\n}\n",x.VERTEX_SHADER),I(D,"\nprecision mediump float;\nuniform highp vec3 playerLightPosition;\nuniform float inSurfaceSensitivity;\nuniform float inFrameTime;\nvarying highp vec3 vColor;\nvarying highp vec3 vNormal;\nvarying highp vec3 vPosition;\n\nconst vec3 AMBIENT_LIGHT = vec3(0.2, 0.2, 0.3);\nconst vec3 PLAYER_LIGHT_COLOR = vec3(0., 1., 1.);\nconst vec2 s = vec2(1, 1.7320508);\nvec4 getHex(vec2 p){\n vec4 hC = floor(vec4(p, p - vec2(.5, 1))/s.xyxy) + .5;\n vec4 h = vec4(p - hC.xy*s, p - (hC.zw + .5)*s);\n return dot(h.xy, h.xy)<dot(h.zw, h.zw) ? vec4(h.xy, hC.xy) : vec4(h.zw, hC.zw + 9.43);\n}\n\nfloat hash21(vec2 p){ return fract(sin(dot(p, vec2(141.173, 289.927)))*43758.5453); }\n\nfloat hex(vec2 p) {\n vec4 h = getHex(p);\n return sin(hash21(h.zw)*8. + inFrameTime) * 0.5 + 0.5;\n}\n\n\nvoid main(void) {\n\n vec3 normal = normalize(vNormal);\n\n vec3 surfaceToLightDirection = normalize(vPosition - vec3(playerLightPosition.x, -1., playerLightPosition.z));\n float directional = max(dot(normal, surfaceToLightDirection), 0.0);\n\n float distanceToPlayer2D = distance(vPosition.xz, playerLightPosition.xz);\n float spotLight = max(0.3 - vPosition.y, 0.) * max(0., 1. - distanceToPlayer2D * 1.1);\n\n vec3 light = vColor * (AMBIENT_LIGHT + vec3(mix(1., directional + spotLight, inSurfaceSensitivity)))\n + vec3(4.5 * spotLight * spotLight * inSurfaceSensitivity);\n\n if (normal.y > 0.95 && normal.y < 1.05 && vPosition.y > 0.) {\n light *= mix(0.6, 0.8, 1.-hex(vPosition.xz*5.));\n }\n\n float fog = 1. - smoothstep(0.1, 10., vPosition.y);\n gl_FragColor = vec4(light * fog, 1.);;\n}\n",x.FRAGMENT_SHADER),x.linkProgram(D),!x.getProgramParameter(D,x.LINK_STATUS))throw Error(x.getProgramInfoLog(D));const B=x.getUniformLocation(D,"Pmatrix"),V=x.getUniformLocation(D,"Vmatrix"),z=x.getAttribLocation(D,"position"),k=x.getAttribLocation(D,"normal"),M=x.getAttribLocation(D,"color"),G=x.getUniformLocation(D,"playerLightPosition"),H=x.getUniformLocation(D,"inTranslation"),O=x.getUniformLocation(D,"inAmbientColor"),J=x.getUniformLocation(D,"inSurfaceSensitivity"),Q=x.getUniformLocation(D,"inFrameTime"),Z=x.getUniformLocation(D,"inFade");this.accumulator=0;const yy=(y,e)=>y.sub(e.mul(1-20*this.accumulator));this.resetCamera=()=>{N=null},this.setCamera=(y,t)=>{const o=yy(y,t),x=[o.x,250,-o.y-100];null===N&&(N=x);const n=q.sub(x,N),r=q.len(n);r>0&&(N=q.add(N,q.mul(q.normalize(n),.001*e.pow(r,2)))),b=1+(N[2]-x[2])/1e3,T=-(N[0]-x[0])/3e3,F[0]=-o.x*P,F[2]=o.y*P},this.bg=()=>{t(),x.enable(x.DEPTH_TEST),x.depthFunc(x.LEQUAL),x.clearColor(0,0,0,1),x.clearDepth(1),x.viewport(0,0,h,u),x.clear(x.COLOR_BUFFER_BIT|x.DEPTH_BUFFER_BIT)};let ey=0,ty=0,iy=0,ay=0,ly=0;this.timer=y=>{const t=1-y/13,o=e.ceil(13-y);if(ay!==o||y-ey>.2){ly&&(r.className=""),ey=y;let e=new Y(t,1-t);e=e.normalize();const x=E(255*e.y),n=E(255*e.x);if(x!==ty||n!==iy){ty=x,iy=n;const y=E(128*e.x*e.x);r.style.color=`rgb(${x},${n},${y})`}ay!==o&&(ay=o,4>o&&(ly=1,r.className="x"),r.innerText=o)}};let cy=1,dy=0;const my=(y,e)=>{let t;(!e||0===e.x&&0===e.y)&&(t=y._a),void 0===t&&(t=w(-e.y,e.x),y._a=t);let o=y._r;return y._r=o=((y,e,t)=>{const o=(e-y)%L;return y+(2*o%L-o)*R(t)})(void 0!==o?o:t,t,12*cy),A/2-o};this.player=y=>{const e=yy(y.position,y.movementVector);t(),$(_,-e.x*P,-3.1*P,e.y*P),W(_,my(y,y.drawMovementVector)),x.uniformMatrix4fv(V,0,_),x.uniform3f(O,1,1,1),x.drawElements(x.TRIANGLES,sy.player.ibCount,x.UNSIGNED_SHORT,2*sy.player.ibStart)},this.ghost=y=>{if(y.dead)return 0;const e=yy(y.position,y.movementVector);return t(),$(_,-e.x*P,-3*P,e.y*P),W(_,my(y,y.movementVector)),x.uniformMatrix4fv(V,0,_),x.drawElements(x.TRIANGLES,sy.ghost.ibCount,x.UNSIGNED_SHORT,2*sy.ghost.ibStart),1};let py,hy,uy=0,fy=4;const gy=new i;this.level=(y,e,t,o)=>{fy=o,cy=t,y.id!==hy&&(hy=y.id,py=0,gy.clear()),uy=R(uy+(4===fy?-cy:cy)),x.enable(x.CULL_FACE),x.cullFace(x.BACK),x.useProgram(D),x.uniform3f(H,0,0,0),x.uniform3f(O,1,1,1),x.uniformMatrix4fv(B,0,U),x.uniformMatrix4fv(V,0,_),x.uniform3fv(G,F),x.uniform1f(Q,e),x.uniform1f(J,uy),x.uniform1f(Z,uy),x.bindBuffer(x.ARRAY_BUFFER,c),x.vertexAttribPointer(z,3,x.FLOAT,0,0,0),x.enableVertexAttribArray(z),x.bindBuffer(x.ARRAY_BUFFER,d),x.vertexAttribPointer(k,3,x.FLOAT,1,0,0),x.enableVertexAttribArray(k),x.bindBuffer(x.ARRAY_BUFFER,m),x.vertexAttribPointer(M,3,x.FLOAT,0,0,0),x.enableVertexAttribArray(M),x.bindBuffer(x.ELEMENT_ARRAY_BUFFER,p),x.drawElements(x.TRIANGLES,y.ibCount,x.UNSIGNED_SHORT,2*y.ibStart);for(const e of y.doors)e.open||x.drawElements(x.TRIANGLES,e.ibCount,x.UNSIGNED_SHORT,2*e.ibStart);x.uniform3f(H,-y.start.x*P,P,y.start.y*P),dy=uy*R(dy+cy*(1===fy?-2:3)),x.uniform1f(J,dy/3),x.uniform3f(O,.2*dy,(1-dy)/4,.5),x.drawElements(x.TRIANGLES,sy.pad.ibCount,x.UNSIGNED_SHORT,2*sy.pad.ibStart),x.uniform1f(J,.4*uy),x.uniform3f(H,-y.end.x*P,3*P,y.end.y*P),py=C(py,C(.7,1,1-S(f(1.5*e))),4*cy),x.uniform3f(O,0,py/1.3,py);const n=y.last?sy.core:sy.pad;x.drawElements(x.TRIANGLES,n.ibCount,x.UNSIGNED_SHORT,2*n.ibStart);for(const t of y.switches){const{uid:y,pressed:o}=t;let n=gy.get(y);n||gy.set(y,n={r:1,g:0,p:0});const{r,g:s,p:i}=n;n.r=C(r,o?.1:C(.7,1,1-S(f(3*e))),4*cy),n.g=C(s,o?.3:0,5*cy),n.p=C(n.p,o?3.8*P:0,8*cy),x.uniform1f(J,uy*s),x.uniform3f(H,-t.x*P,i,t.y*P),x.uniform3f(O,r,s,0),x.drawElements(x.TRIANGLES,sy.pad.ibCount,x.UNSIGNED_SHORT,2*sy.pad.ibStart)}x.uniform1f(J,0),x.uniform3f(H,0,0,0)},this.titleScreen=()=>{},this.endScreen=()=>{}}(a.getElementById("c")),ly=new function(y){let e,t,o=[],x=0,n=[],s=0,i=0,l=0;const c=a.getElementById("L");let d=-1,u={};const f=()=>{O.death(),l=3};this.draw=(y,n,r)=>{switch(ay.accumulator=y,l){case 0:ay.titleScreen();break;case 1:case 4:case 3:case 2:if(ay.setCamera(t.position,t.movementVector),ay.bg(),ay.level(e.getLevel(),n,r,l),ay.player(t),2===l)for(const y of o)ay.ghost(y);ay.timer(x/20);break;case 5:ay.endScreen()}},this.tick=()=>{if(1===l&&d!==s&&(d=s,c.innerText=e.last?"THE MEMORY CORE":`Level ${s}`,c.className="a",r(()=>{c.className=""},2e3)),1!==l&&4!==l||i>0&&(i-=.05),3===l){let y=new Y(0,0);for(;40>y.len()&&x>0;)y=y.sub(n[--x]);return ay.scale/=.95,t.forceMove(y),void(0===x&&(()=>{for(const y of o)y.reset();o.push(new p(n,e)),o.length>4&&o.shift(),x=0,n=[],e.reset(),t=new m(e),l=1,ay.scale=1.5})())}if(2===l){if(e.completed)return l=4,t.movementVector=new Y(0,0),i=1,void O.win();if(260===x)return void f();n[x]=t.move(u);for(const y of o)y.tick(x);++x}4!==l||i>0||(e.last?a.body.className="started won":(this.loadLevel(s+1),l=1,i=1))},this.buttonDown=y=>{if(0===l)return a.body.className="started",l=1,void(i=1);1!==l||i>0||(l=2),u[y]=1,"back"===y&&f()},this.buttonUp=y=>{void 0===y&&(u={}),u[y]=0},this.loadLevel=r=>{s=r,y.length>r||(l=5),e=new h(y[r]),n=[],t=new m(e),o=[],x=0,ay.resetCamera()},this.loadLevel(s)}(I);let cy;ly.loadLevel(0),r(()=>{a.getElementById("intro").className="a"},1);let dy=0;const my=y=>{l(my),void 0===cy&&(cy=y);const e=(y-cy)/1e3;(dy+=e)>.05&&(dy-=.05,ly.tick()),dy>.05&&(dy=.05),ly.draw(dy,y/1e3,e),cy=y};l(my);const py={ArrowUp:"up",KeyW:"up",ArrowDown:"down",KeyS:"down",ArrowLeft:"left",KeyA:"left",ArrowRight:"right",KeyD:"right",Backspace:"back"};o.addEventListener("keydown",y=>(py[y.code]?(ly.buttonDown(py[y.code]),y.preventDefault()):ly.buttonDown("*"),0)),o.addEventListener("keyup",y=>(py[y.code]&&(ly.buttonUp(py[y.code]),y.preventDefault()),0));let hy=0,uy=0,fy=0;o.addEventListener("touchstart",y=>{hy=y.changedTouches[0].clientX,uy=y.changedTouches[0].clientY}),o.addEventListener("touchmove",y=>{const t=y.changedTouches[0].clientX-hy,o=y.changedTouches[0].clientY-uy;return ly.buttonUp(),ly.buttonDown(e.abs(t)>e.abs(o)?t>0?"right":"left":o>0?"down":"up"),y.preventDefault(),0}),o.addEventListener("touchend",()=>{fy||(a.documentElement.requestFullscreen({navigationUI:"hide"}),fy=1),ly.buttonUp()}),o.addEventListener("touchcancel",()=>{ly.buttonUp()})})(JSON,Math,Array,window,Uint16Array,Audio,setTimeout,Float32Array,Map,document,requestAnimationFrame);</script>
|
|
</body>
|
|
</html> |