parity overlay

This commit is contained in:
heav-4 2020-07-19 15:45:10 +01:00 committed by GitHub
parent 0a4a8fa56a
commit 63b2ac63d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 45 additions and 14 deletions

View File

@ -13,6 +13,8 @@
var kills=0;*/ var kills=0;*/
let frigidmode=false let frigidmode=false
let paritychallenge=false let paritychallenge=false
let parityoverlay=false
let prevkilled=false // parity challenge thingy.
const solid={ const solid={
"player":true, "player":true,
"bee":true, "bee":true,
@ -51,12 +53,8 @@
this.meta=meta; this.meta=meta;
this.cx=x; this.cx=x;
this.cy=y; this.cy=y;
if (this.type=="bee"||this.type=="apioform"||this.type=="apiodiagoform"||this.type=="apiokinetoform"||this.type=="apiopyroform"||this.type=="cryoapioform"){ this.meta.clock=0;
this.meta.clock=0; this.meta.cooldown=0
}
if (this.type=="apiopyroform"||this.type=="cryoapioform"){
this.meta.cooldown=0
}
this.meta.frozen=0 this.meta.frozen=0
} }
} }
@ -217,6 +215,16 @@
case "player": case "player":
ctx.fillStyle="#000000" ctx.fillStyle="#000000"
ctx.fillRect(ent.cx*10,ent.cy*10,10,10) ctx.fillRect(ent.cx*10,ent.cy*10,10,10)
if (parityoverlay&&paritychallenge){
ctx.fillStyle="#ffffff"
ctx.textBaseline="middle"
ctx.textAlign="center"
ctx.font="10px monospace";
if (ent.x%2==0&&ent.y%2==0) ctx.fillText("a",ent.cx*10+5,ent.cy*10+5)
if (ent.x%2==1&&ent.y%2==0) ctx.fillText("b",ent.cx*10+5,ent.cy*10+5)
if (ent.x%2==0&&ent.y%2==1) ctx.fillText("d",ent.cx*10+5,ent.cy*10+5)
if (ent.x%2==1&&ent.y%2==1) ctx.fillText("c",ent.cx*10+5,ent.cy*10+5)
}
break; break;
case "bee": case "bee":
if (ent.meta.clock%2==0) ctx.fillStyle="#808020" if (ent.meta.clock%2==0) ctx.fillStyle="#808020"
@ -247,6 +255,20 @@
case "apiopariform": case "apiopariform":
ctx.fillStyle="#808080" ctx.fillStyle="#808080"
ctx.fillRect(ent.cx*10,ent.cy*10,10,10) ctx.fillRect(ent.cx*10,ent.cy*10,10,10)
if (parityoverlay&&paritychallenge){
ctx.fillStyle="#ffffff"
ctx.textBaseline="middle"
ctx.textAlign="center"
ctx.font="10px monospace";
if (ent.x%2==0&&ent.y%2==0) ctx.fillText("a",ent.cx*10+5,ent.cy*10+5)
if (ent.x%2==1&&ent.y%2==0) ctx.fillText("b",ent.cx*10+5,ent.cy*10+5)
if (ent.x%2==0&&ent.y%2==1) ctx.fillText("d",ent.cx*10+5,ent.cy*10+5)
if (ent.x%2==1&&ent.y%2==1) ctx.fillText("c",ent.cx*10+5,ent.cy*10+5)
}
break;
case "apiocryokinetoform":
ctx.fillStyle="#FFFFFF"
ctx.fillRect(ent.cx*10,ent.cy*10,10,10)
break; break;
} }
ent.cx+=(ent.x-ent.cx)*0.4 ent.cx+=(ent.x-ent.cx)*0.4
@ -340,11 +362,15 @@
makeent(3,3,"player",{}) makeent(3,3,"player",{})
px=3 px=3
py=3 py=3
prevkilled=false
break; break;
case 80: case 80:
paritychallenge=!paritychallenge paritychallenge=!paritychallenge
turn({keyCode:82}) turn({keyCode:82})
break; break;
case 79:
parityoverlay=!parityoverlay
break;
} }
if (px+dx<0||px+dx>49||py+dy<0||py+dy>49){ if (px+dx<0||px+dx>49||py+dy<0||py+dy>49){
maketurn=false maketurn=false
@ -365,6 +391,7 @@
for (var i=entities[nent].length-1;i>=0;i--){ for (var i=entities[nent].length-1;i>=0;i--){
if (entities[nent][i].meta.dead!==undefined){ if (entities[nent][i].meta.dead!==undefined){
entities[nent].splice(i,1) entities[nent].splice(i,1)
prevkilled=true
} }
} }
} }
@ -577,14 +604,18 @@
} }
} }
if (paritychallenge){ if (paritychallenge){
while (true){ if (prevkilled){
let cx=Math.floor(Math.random()*48)+1 prevkilled=false
let cy=Math.floor(Math.random()*48)+1 }else{
let s=issolid(cx+" "+cy) while (true){
if (!s){ let cx=Math.floor(Math.random()*48)+1
makeent(cx,cy,"apiopariform",{}) let cy=Math.floor(Math.random()*48)+1
} else continue let s=issolid(cx+" "+cy)
break if (!s){
makeent(cx,cy,"apiopariform",{})
} else continue
break
}
} }
} }
if (php<=0||px<0||px>49||py<0||py>49){ if (php<=0||px<0||px>49||py<0||py>49){