for(_='Math.RRabs(QF(P+!P3)O(b-2?NP2)Lor(K-g)J-f)H&&GG(=0n[0>){};onkey?-+=",c.fill),=d.client\\u2650,fKi of p)i.=function(dthis))==b ,f,g,.5:!b|3==b?.8:1,a.widthd.keyCode%37]=a.heightL4:4p.push(new C(,/2,/2,Cd,ke,b.cif(eh2<b,c.font=2*e+"px aStyle=b+41<b?"hsl("+80*N4+b:l/9)+",80%,50%)":"#FFF":"#0005TextNb+4?"740b665be fcd"[3+b]:"588588":m,f-e,g+e/2fd*=f+d>|f+dgk*=g+k>|g+kb&-4<b|1 e*=13<e1>b?.9:.99:0b||(d2]-0],k3]-1],0==l%5G(rH/9,(vJ/918,-1);b(f,g,e,b,)}.ae.bt,u,x,I,yeG0<b&-3<I&1>IGl-I!I&50<l&!Pw)3 dt-f9:9,ku-g9:94 40<++eG0e=25,3,k=(d=L?0:)?0:5 P9)||(tH/8(uJ/8051,d=,k=,QtH<e+x&QuJ<e+x02*e,-3,.a(y.a()}setInterval(Ec();0==++l%50&9<wG--w;9<m--m,h);if(!h)fKi=25*++m,w=50-2*m,p=[],-425,l;--i;)PP25+P9LOO+2/9,-2;h},16);Freturn RfloK1E6*Rrandom(%ddown2up0onmousemoverX;vYp=[],n=[0],m=l=r=v=h=w;';G=/[^ -FIMS-}]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
//////////////////////////////////////////////////
// Queen's Gambit - AKA Chesstron 1024
// Frank Force 2019
//////////////////////////////////////////////////
// minfiy notes
// crush with closure
// combine =0s at end of file
// replace for loops with for(X of p)
// replace empty function args
// actor object
A=function(vx, vy, x, y, s, type)
{
// types...
// 5 bishop - moves randomly diagonals, shoots at player
// 4 rook - moves randomly at right angles, spawns pawns
// 3 pawn - moves towards player in short steps
// 2 number - stationary enemy, shows level number
// 1 horse - enemy bullet
// >0 enemies
// 0 player
// <0 other stuff
// -1 heart - player bullet
// -2 enemy killbox at start of round
// -3 explosion effect
// -4 background
this.U=function() // update
{
if (s)
{
enemycount += type > 2;
// draw actor
c.font = 2*s+"px a";
//c.fillStyle="#"+(type>2?"F00":type==-4?"0005":"FFF"); // red/wite/black coloring
c.fillStyle=type+4?type>-1?"hsl("+80*(type-2?4+type:framecount/9)+",80%,50%)":"#FFF":"#0005";
c.fillText(type-2?type+4?"❀♛♥♛♞ ♟♜♝"[3+type]:"██":level, x-s,y+s/2);
// update position, bounce off walls, and apply damping
x += vx *=x+vx > a.width | x+vx < 0?-.5:(!type | type == 3)?.8:1;
y += vy *=y+vy > a.height | y+vy < 0?-.5:(!type | type == 3)?.8:1;
if (type < 0 & type > -4 | type == 1) // heart, explosion, killbox, and horse
{
// get smaller and die over time
s *= s > 13?type<-1?.9:.99:0;
}
if (!type) // player
{
// movement controls
vx += inputIsDown[2] - inputIsDown[0];
vy += inputIsDown[3] - inputIsDown[1];
if (framecount%5==0) // shoot
{
// push new bullet moving in direction of mouse
//var px = mouseX - x,
// py = mouseY - y,
// norm = .05*Math.sqrt(px * px + py * py);
// push new bullet moving in direction of mouse
//actorList.push(new A(x,y,px/norm,py/norm,20, -1));
actorList.push(new A((mouseX - x)/9,(mouseY - y)/9,x,y,18, -1)); // simplified without normal
}
}
// cross update with each other actor
for(j=0;j<actorList.length;)
actorList[j++].C(x,y,s,type,this);
}
}
this.S=function() { s = 0; } // set size to 0 to indicate death
this.C=function(ox,oy,os,otype,that) // cross update
{
if (s && type > 0 & otype > -3 & otype < 1 && framecount - otype) // enemy vs bullet or player
{
if (!otype & framecount > 50 & !R(agro)) // enemy react to player
{
if (type == 3) // pawn
{
// move towards player
vx += ox-x<0?-9:9;
vy += oy-y<0?-9:9;
}
if (type == 4) // rook
{
// get larger and split into smaller copy of self and pawn at max size
if (++s>40)
actorList.push(new A(0,0,x,y,s=25,3));
// move randomly in 90 degree angles
vx = R(2)?0:R(2)?-4:4;
vy = vx?0:R(2)?-4:4;
}
if (type == 5) // bishop
{
// shoot at player
//if (++s>40)
// actorList.push(new A((ox - x)/80,(oy - y)/80,x,y,s, 1)),s=25;
if (!R(9))// && framecount > 200)
actorList.push(new A((ox - x)/80,(oy - y)/80,x,y,50, 1));
// move randomly on diagonals
vx = R(2)?-4:4;
vy = R(2)?-4:4;
}
}
// hit check
//if ((ox-x)*(ox-x) < (s+os)*(s+os) && (oy-y)*(oy-y) < (s+os)*(s+os)) // without Math.abs
if (Math.abs(ox - x) < s+os & Math.abs(oy - y) < s+os)
{
actorList.push(new A(0,0,x,y,2*s,-3)); // hit effect
this.S();
//if (otype) // godmode
that.S();
}
}
}
}
// main game loop
setInterval(G=function() // loop
{
for(i=0;i<actorList.length;) // update actors
actorList[i++].U();
// increase agro over time
if (++framecount%50==0&agro>9)
--agro;
if (level >9) --level,enemycount=0; // kill screen
if (!enemycount) // all enemies dead, generate new level
{
// increase starting agro and number with level
i = ++level*25;
agro = 50 - level*2;
// reset actor list
actorList = [];
actorList.push(new A(0,0,a.width/2,a.height/2,a.width,-4)); // background actor
actorList.push(new A(0,0,a.width/2,a.height/2,25,framecount=0)); // player
for(;--i;)
{
actorList.push(new A(0,0,R(a.width),R(a.height),25 + R(9),R(2)+!R(3)+!R(3)+2)); // spawn random enemy
actorList.push(new A(0,0,a.width/2,a.height/2,a.width/9,-2)); // spawn 1 kill box for each enemy (prevent enemies spawning near player)
}
}
enemycount = 0;
},16);
// simple random number maker
R=function(x){return Math.floor(Math.random() * 1E6) % x;}
// input
onkeydown = function(x) { inputIsDown[x.keyCode%37]=2; }
onkeyup = function(x) { inputIsDown[x.keyCode%37]=0; }
onmousemove = function(x) { mouseX = x.clientX; mouseY = x.clientY; }
// init
var actorList=[], inputIsDown=[0,0,0,0], level=0, framecount=0, mouseX=0, mouseY=0, enemycount=0, agro=0;