From f75aef48e9d60374143acb35dbaea6e35f7218b4 Mon Sep 17 00:00:00 2001 From: Zheng Lin Lei Date: Sun, 22 Oct 2023 23:21:54 +0200 Subject: [PATCH] Controlled lag checking before release v0.1.6-b2 --- js/script.js | 36 +++++++++++++++++++++++++----------- js/script.min.js | 2 +- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/js/script.js b/js/script.js index 3c7b2b2..e843dc6 100644 --- a/js/script.js +++ b/js/script.js @@ -18,6 +18,8 @@ let GAME_ = { lagWarning: { enable: true, // Once the warning has been showed, disable it lastWarning: 0, // Enable the warning after 30 seconds + frames: 0, // Count the frames, when started lagging. If the frames are over framesMax, show the warning + framesMax: 60 * 3, // 3 seconds } }, end: false, @@ -35,6 +37,7 @@ let GAME_ = { service: true, // If this service mus be disable, change value to false enable: false, frames: 0, + framesMax: 5, // Take screenshot after x frames callback: null, blob: null @@ -48,6 +51,7 @@ let GAME_ = { service: true, // If this service must be disable, change value to false enable: false, frames: 0, + framesMax: 20, finished: false }, // Zoom out the camera fter every game over } @@ -594,7 +598,7 @@ window.addEventListener('load', ()=>{ GAME_.zoomOut.frames ++; - if (GAME_.zoomOut.frames >= 20) { + if (GAME_.zoomOut.frames >= GAME_.zoomOut.framesMax) { GAME_.zoomOut.enable = false; GAME_.zoomOut.frames = 0; GAME_.zoomOut.finished = true; @@ -610,7 +614,7 @@ window.addEventListener('load', ()=>{ // Once the canvas(webgl2) buffer has been cleaned, it can not take screenshot anymore. if (GAME_.screenshot.enable) { // TAKE THE SCREENSHOT AFTER 5 FRAMES FOR MORE PRECISE IMAGE STATUS - if(GAME_.screenshot.frames >= 5) { + if(GAME_.screenshot.frames >= GAME_.screenshot.framesMax) { // TAKE THE SCREENSHOT AFTER ZOOMOUT, NOT BEFORE OR IN PROCESS if(GAME_.zoomOut.finished) { // CREATE A EXTRA CANVAS @@ -696,16 +700,26 @@ window.addEventListener('load', ()=>{ GAME_.fpsCtrl.mFps = Math.round(1000 / GAME_.fpsCtrl.elapsed) - (GAME_.fpsCtrl.forceLag ? 30 : 0); // Check lag if (GAME_.fpsCtrl.mFps < GAME_.fpsCtrl.fps / 2) { - // Lag warning - if (GAME_.fpsCtrl.lagWarning.lastWarning + 30000 < GAME_.fpsCtrl.now) { - GAME_.fpsCtrl.lagWarning.lastWarning = GAME_.fpsCtrl.now; - GAME_.fpsCtrl.lagWarning.enable = true; - } - - if (GAME_.fpsCtrl.lagWarning.enable) { - GAME_.fpsCtrl.lagWarning.enable = false; - alertLog("May be laggy. Try to close other apps"); + if (GAME_.fpsCtrl.lagWarning.frames >= GAME_.fpsCtrl.lagWarning.framesMax) { + // Lag warning + if (GAME_.fpsCtrl.lagWarning.lastWarning + 30000 < GAME_.fpsCtrl.now) { + GAME_.fpsCtrl.lagWarning.lastWarning = GAME_.fpsCtrl.now; + GAME_.fpsCtrl.lagWarning.enable = true; + } + + if (GAME_.fpsCtrl.lagWarning.enable) { + GAME_.fpsCtrl.lagWarning.enable = false; + alertLog("May be laggy. Try to close other apps"); + + // Reset frames + GAME_.fpsCtrl.lagWarning.frames = 0; + } + } else { + GAME_.fpsCtrl.lagWarning.frames++; } + } else { + // Reset frames + GAME_.fpsCtrl.lagWarning.frames = 0; } // Get ready for next frame by setting then = now diff --git a/js/script.min.js b/js/script.min.js index e7a886a..c706a0c 100644 --- a/js/script.min.js +++ b/js/script.min.js @@ -1 +1 @@ -let GAME_={platform:navigator.userAgent.match(/(iPad|iPhone|iPod)/g)?"ios":navigator.userAgent.match(/(Android)/g)?"android":navigator.userAgent.match(/(Windows)/g)?"windows":navigator.userAgent.match(/(Mac)/g)?"mac":navigator.userAgent.match(/(Linux)/g)?"linux":"unknown",status:!1,fpsCtrl:{forceLag:!1,fps:60,mFps:0,fpsInterval:0,now:0,then:0,delta:0,lagWarning:{enable:!0,lastWarning:0}},end:!1,active:!1,score:0,combo:0,gamesPlayed:0,bestResult:window.localStorage.getItem("bestResult")?window.localStorage.getItem("bestResult"):0,newRecord:!1,designPalette:0,screenshot:{service:!0,enable:!1,frames:0,callback:null,blob:null},botMode:!1,confetti:{range:[30,50]},zoomOut:{service:!0,enable:!1,frames:0,finished:!1}};const colorDesign=[[30,70,50],[120,80,60],[224,68,62],[251,50,60],[339,62,48],[231,50,47],[165,30,68]],boxSize={x:3,y:1,z:3,range:10},c_width=10,cameraPos={width:c_width,height:c_width*(window.innerHeight/window.innerWidth),near:1,far:100,size:700{try{var e=stackBoxArr[stackBoxArr.length-1],t=stackBoxArr[stackBoxArr.length-2],o=e.direction,r=e.threejs.position[o]-t.threejs.position[o],n=Math.abs(r),s="x"===o?e.width:e.depth,a=(s-n)/s;(i||.95)<=a&&(fncStart(),c)&&console.log(a)}catch(e){fncStart()}},e||20)}window.addEventListener("load",()=>{let c=document.querySelector(".result-area"),l=document.querySelector(".point-result"),d=document.querySelector(".score-tab"),h=document.querySelector(".combo-strike"),m=document.querySelector(".combo-extra-point");var e=document.querySelector("#click-event");let p=document.querySelector("#record-share");function A(e=!1){let t=u(colorDesign[GAME_.designPalette][0]+120+stackBoxArr.length,colorDesign[GAME_.designPalette][1],colorDesign[GAME_.designPalette][2]);scene.background=new THREE.Color(t),e&&(t=u(colorDesign[GAME_.designPalette][0]+120+stackBoxArr.length,colorDesign[GAME_.designPalette][1],10)),document.querySelector('meta[name="theme-color"]').setAttribute("content",t),"windows"===GAME_.platform&&document.querySelector('meta[name="msapplication-TileColor"]').setAttribute("content",t)}function g(e){l.innerHTML=e}function E(e,t,o,r,n){e=M(e,boxSize.y*stackBoxArr.length,t,o,r,!1);e.direction=n,e.positive=!0,stackBoxArr.push(e)}function M(e,t,o,r,n,s=!1){var a=s?4*(stackBoxArr.length-1):4*stackBoxArr.length,a=new THREE.Color(u(colorDesign[GAME_.designPalette][0]+a,colorDesign[GAME_.designPalette][1],colorDesign[GAME_.designPalette][2])),i=new THREE.BoxGeometry(r,boxSize.y,n),a=new THREE.MeshLambertMaterial({color:a}),c=new THREE.Mesh(i,a),l=(c.position.set(e,t,o),new CANNON.Box(new CANNON.Vec3(r/2,boxSize.y/2,n/2))),s=new CANNON.Body({mass:s?5:0,shape:l});return s.position.set(e,t,o),world.addBody(s),scene.add(c),{threejs:c,geometry:i,material:a,cannonjs:s,x:e,y:t,z:o,width:r,depth:n}}function u(t,e,o){o=101{e=(e+t/30)%12,e=o-r*Math.max(Math.min(e-3,9-e,1),-1);return Math.round(255*e).toString(16).padStart(2,"0")};return"#"+e(0)+e(8)+e(4)}function w(){camera.right=cameraPos.width/cameraPos.size,camera.left=cameraPos.width/-cameraPos.size,camera.top=cameraPos.height/cameraPos.size,camera.bottom=cameraPos.height/-cameraPos.size,camera.updateProjectionMatrix()}function f(){return"now"in window?now():("now"in performance&&"performance"in window?performance:Date).now()}function t(e){document.querySelector("#noti-popup").classList.remove("display"),document.querySelector("#noti-popup-text").innerText=e,document.querySelector("#noti-popup").classList.add("display"),setTimeout(()=>document.querySelector("#noti-popup").classList.remove("display"),5200)}(world=new CANNON.World).gravity.set(0,-9.8,0),world.broadphase=new CANNON.NaiveBroadphase,world.solver.interations=40,g(GAME_.bestResult),scene=new THREE.Scene,A(hslDark=!0),E(0,0,boxSize.x,boxSize.z,"x");var o=new THREE.AmbientLight(16777215,.6),o=(scene.add(o),new THREE.DirectionalLight(16777215,.6));function r(){var e,t;GAME_.end?(stackBoxArr[stackBoxArr.length-1].threejs.position.copy(stackBoxArr[stackBoxArr.length-1].cannonjs.position),stackBoxArr[stackBoxArr.length-1].threejs.quaternion.copy(stackBoxArr[stackBoxArr.length-1].cannonjs.quaternion),GAME_.zoomOut.enable&&(cameraPos.size-=.02,w(),GAME_.zoomOut.frames++,20<=GAME_.zoomOut.frames)&&(GAME_.zoomOut.enable=!1,GAME_.zoomOut.frames=0,GAME_.zoomOut.finished=!0)):(t=(e=stackBoxArr[stackBoxArr.length-1]).positive?.15:-.15,e.threejs.position[e.direction]>=boxSize.range-5&&(e.positive=!1),e.threejs.position[e.direction]<=-(boxSize.range-5)&&(e.positive=!0),e.threejs.position[e.direction]+=t,e.cannonjs.position[e.direction]+=t,camera.position.y{e.threejs.position.copy(e.cannonjs.position),e.threejs.quaternion.copy(e.cannonjs.quaternion)}),renderer.render(scene,camera),GAME_.screenshot.enable&&(5<=GAME_.screenshot.frames?GAME_.zoomOut.finished&&(DrawCanvasCopy(renderer.domElement,e=>{e.fillStyle="rgba(0, 0, 0, 0.2)",e.fillRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle="#ffffff",e.font="32px monospace";var t="NEW RECORD",o=e.measureText(t).width;e.fillText(t,e.canvas.width/2-o/2,e.canvas.height/2-100),e.font="bold 64px monospace",t=GAME_.score,o=e.measureText(t).width,e.fillText(t,e.canvas.width/2-o/2,e.canvas.height/2+50),GAME_.botMode&&(e.save(),e.translate(e.canvas.width/2,e.canvas.height/2+50),e.rotate(-Math.PI/8),e.fillStyle="rgba(255, 0, 0, 0.6)",e.font="bold 64px monospace",o=e.measureText(t="FAKE").width,e.fillText(t,-o/2,0),e.strokeStyle="rgba(255, 0, 0, 0.5)",e.lineWidth=5,e.strokeRect(-(o/2+10),-51.152,o+20,56.152),e.restore())},e=>{var t=document.createElement("img");const o=URL.createObjectURL(e);t.onload=()=>{URL.revokeObjectURL(o)},t.src=o,GAME_.screenshot.blob=e,GAME_.screenshot.callback(t)}),GAME_.screenshot.enable=!1,GAME_.screenshot.frames=0):GAME_.screenshot.frames++)}function _(){requestAnimationFrame(_),GAME_.fpsCtrl.now=f(),GAME_.fpsCtrl.elapsed=GAME_.fpsCtrl.now-GAME_.fpsCtrl.then,GAME_.fpsCtrl.elapsed>GAME_.fpsCtrl.fpsInterval&&(GAME_.fpsCtrl.mFps=Math.round(1e3/GAME_.fpsCtrl.elapsed)-(GAME_.fpsCtrl.forceLag?30:0),GAME_.fpsCtrl.mFps{var e,t,o,r,n,s,a,i;GAME_.status?(o=stackBoxArr[stackBoxArr.length-1],n=stackBoxArr[stackBoxArr.length-2],r=o.direction,n=o.threejs.position[r]-n.threejs.position[r],i=Math.abs(n),0<(s=(a="x"===r?o.width:o.depth)-i)?(a=s/a,i<.2?([9,19,29,39,49].includes(GAME_.combo)&&(m.classList.add("active"),setTimeout(()=>{m.classList.remove("active")},1100),GAME_.score+=10),GAME_.combo+=1,h.innerHTML="x"+GAME_.combo,h.classList.add("open"),setTimeout(()=>{h.classList.remove("open")},700)):GAME_.combo&&(GAME_.combo=0),e="x"===r?s:o.width,t="z"===r?s:o.depth,o.width=e,o.depth=t,o.threejs.scale[r]=a,o.threejs.position[r]-=n/2,o.cannonjs.position[r]-=n/2,a=new CANNON.Box(new CANNON.Vec3(e/2,boxSize.y/2,t/2)),o.cannonjs.shapes=[],o.cannonjs.addShape(a),.01<=i&&(a=Math.sign(n)*(s/2+i/2),n={x:"x"===r?o.threejs.position.x+a:o.threejs.position.x,z:"z"===r?o.threejs.position.z+a:o.threejs.position.z,width:"x"===r?i:e,depth:"z"===r?i:t},s=n.z,a=n.width,i=n.depth,n=M(n=n.x,boxSize.y*(stackBoxArr.length-1),s,a,i,!0),outBoxArr.push(n)),E("x"===r?o.threejs.position.x:-(boxSize.range-1),"z"===r?o.threejs.position.z:-(boxSize.range-1),e,t,"x"===r?"z":"x"),GAME_.score++,g(GAME_.score)):(GAME_.end=!0,world.remove(o.cannonjs),s=new CANNON.Box(new CANNON.Vec3(o.width/2,boxSize.y/2,o.depth/2)),(a=new CANNON.Body({mass:5,shape:s})).position.set(o.threejs.position.x,o.threejs.position.y,o.threejs.position.z),world.addBody(a),o.cannonjs=a,c.classList.toggle("disable"),l.classList.toggle("active"),GAME_.status=!1,GAME_.score>GAME_.bestResult&&(playConfetti(GAME_.confetti.range[0],GAME_.confetti.range[1]),GAME_.botMode||(GAME_.bestResult=GAME_.score,window.localStorage.setItem("bestResult",GAME_.score)),d.classList.add("new"),GAME_.newRecord=!0,GAME_.screenshot.service)&&(GAME_.screenshot.callback=e=>{p.replaceChild(e,p.querySelector("img")),p.classList.add("display")},GAME_.screenshot.enable=!0),GAME_.zoomOut.service&&(GAME_.zoomOut.enable=!0),i=localStorage.getItem("installDismissed")??!1,!enableDownload||"false"!=i&&i||(document.querySelector("#pwa-install").classList.add("display"),0{scene.remove(e.threejs),e.geometry.dispose(),e.material.dispose(),world.removeBody(e.cannonjs)}),outBoxArr.forEach(e=>{scene.remove(e.threejs),e.geometry.dispose(),e.material.dispose(),world.removeBody(e.cannonjs)}),stackBoxArr=[],outBoxArr=[],GAME_.score=0,GAME_.combo=0,A(),E(0,0,boxSize.x,boxSize.z,"x"),document.querySelector("#pwa-install").classList.remove("display"),p.classList.remove("display"),document.querySelector("#noti-popup").classList.remove("display")):(GAME_.fpsCtrl.fps=GAME_.fpsCtrl.forceLag?GAME_.fpsCtrl.fps/2:GAME_.fpsCtrl.fps,GAME_.fpsCtrl.fpsInterval=1e3/GAME_.fpsCtrl.fps,GAME_.fpsCtrl.then=f(),_(),GAME_.active=!0,d.querySelector(".score").innerHTML="SCORE"),g(GAME_.score),E(0,0,boxSize.x,boxSize.z,"z"),c.classList.toggle("disable"),l.classList.toggle("active"),GAME_.newRecord&&(GAME_.newRecord=!1,d.classList.remove("new")),GAME_.status=!0,GAME_.end=!1),A(hslDark=GAME_.end)};o="ontouchstart"in window||navigator.msMaxTouchPoints?"touchstart":"mousedown";e.addEventListener(o,fncStart);let n=!0;window.addEventListener("keydown",function(e){32!==e.keyCode&&40!==e.keyCode&&" "!==e.key||(e.preventDefault(),n&&(n=!1,fncStart()))}),window.addEventListener("keyup",function(e){32!==e.keyCode&&40!==e.keyCode&&" "!==e.key||(n=!0)}),window.addEventListener("resize",e=>{cameraPos.height=c_width*(window.innerHeight/window.innerWidth),cameraPos.size=700{await Blob2Share(GAME_.screenshot.blob)||t("Unable to share. Take screenshot 📸")})}); \ No newline at end of file +let GAME_={platform:navigator.userAgent.match(/(iPad|iPhone|iPod)/g)?"ios":navigator.userAgent.match(/(Android)/g)?"android":navigator.userAgent.match(/(Windows)/g)?"windows":navigator.userAgent.match(/(Mac)/g)?"mac":navigator.userAgent.match(/(Linux)/g)?"linux":"unknown",status:!1,fpsCtrl:{forceLag:!1,fps:60,mFps:0,fpsInterval:0,now:0,then:0,delta:0,lagWarning:{enable:!0,lastWarning:0,frames:0,framesMax:180}},end:!1,active:!1,score:0,combo:0,gamesPlayed:0,bestResult:window.localStorage.getItem("bestResult")?window.localStorage.getItem("bestResult"):0,newRecord:!1,designPalette:0,screenshot:{service:!0,enable:!1,frames:0,framesMax:5,callback:null,blob:null},botMode:!1,confetti:{range:[30,50]},zoomOut:{service:!0,enable:!1,frames:0,framesMax:20,finished:!1}};const colorDesign=[[30,70,50],[120,80,60],[224,68,62],[251,50,60],[339,62,48],[231,50,47],[165,30,68]],boxSize={x:3,y:1,z:3,range:10},c_width=10,cameraPos={width:c_width,height:c_width*(window.innerHeight/window.innerWidth),near:1,far:100,size:700{try{var e=stackBoxArr[stackBoxArr.length-1],t=stackBoxArr[stackBoxArr.length-2],o=e.direction,r=e.threejs.position[o]-t.threejs.position[o],n=Math.abs(r),s="x"===o?e.width:e.depth,a=(s-n)/s;(i||.95)<=a&&(fncStart(),c)&&console.log(a)}catch(e){fncStart()}},e||20)}window.addEventListener("load",()=>{let c=document.querySelector(".result-area"),l=document.querySelector(".point-result"),d=document.querySelector(".score-tab"),m=document.querySelector(".combo-strike"),h=document.querySelector(".combo-extra-point");var e=document.querySelector("#click-event");let p=document.querySelector("#record-share");function A(e=!1){let t=f(colorDesign[GAME_.designPalette][0]+120+stackBoxArr.length,colorDesign[GAME_.designPalette][1],colorDesign[GAME_.designPalette][2]);scene.background=new THREE.Color(t),e&&(t=f(colorDesign[GAME_.designPalette][0]+120+stackBoxArr.length,colorDesign[GAME_.designPalette][1],10)),document.querySelector('meta[name="theme-color"]').setAttribute("content",t),"windows"===GAME_.platform&&document.querySelector('meta[name="msapplication-TileColor"]').setAttribute("content",t)}function g(e){l.innerHTML=e}function M(e,t,o,r,n){e=E(e,boxSize.y*stackBoxArr.length,t,o,r,!1);e.direction=n,e.positive=!0,stackBoxArr.push(e)}function E(e,t,o,r,n,s=!1){var a=s?4*(stackBoxArr.length-1):4*stackBoxArr.length,a=new THREE.Color(f(colorDesign[GAME_.designPalette][0]+a,colorDesign[GAME_.designPalette][1],colorDesign[GAME_.designPalette][2])),i=new THREE.BoxGeometry(r,boxSize.y,n),a=new THREE.MeshLambertMaterial({color:a}),c=new THREE.Mesh(i,a),l=(c.position.set(e,t,o),new CANNON.Box(new CANNON.Vec3(r/2,boxSize.y/2,n/2))),s=new CANNON.Body({mass:s?5:0,shape:l});return s.position.set(e,t,o),world.addBody(s),scene.add(c),{threejs:c,geometry:i,material:a,cannonjs:s,x:e,y:t,z:o,width:r,depth:n}}function f(t,e,o){o=101{e=(e+t/30)%12,e=o-r*Math.max(Math.min(e-3,9-e,1),-1);return Math.round(255*e).toString(16).padStart(2,"0")};return"#"+e(0)+e(8)+e(4)}function u(){camera.right=cameraPos.width/cameraPos.size,camera.left=cameraPos.width/-cameraPos.size,camera.top=cameraPos.height/cameraPos.size,camera.bottom=cameraPos.height/-cameraPos.size,camera.updateProjectionMatrix()}function w(){return"now"in window?now():("now"in performance&&"performance"in window?performance:Date).now()}function t(e){document.querySelector("#noti-popup").classList.remove("display"),document.querySelector("#noti-popup-text").innerText=e,document.querySelector("#noti-popup").classList.add("display"),setTimeout(()=>document.querySelector("#noti-popup").classList.remove("display"),5200)}(world=new CANNON.World).gravity.set(0,-9.8,0),world.broadphase=new CANNON.NaiveBroadphase,world.solver.interations=40,g(GAME_.bestResult),scene=new THREE.Scene,A(hslDark=!0),M(0,0,boxSize.x,boxSize.z,"x");var o=new THREE.AmbientLight(16777215,.6),o=(scene.add(o),new THREE.DirectionalLight(16777215,.6));function r(){var e,t;GAME_.end?(stackBoxArr[stackBoxArr.length-1].threejs.position.copy(stackBoxArr[stackBoxArr.length-1].cannonjs.position),stackBoxArr[stackBoxArr.length-1].threejs.quaternion.copy(stackBoxArr[stackBoxArr.length-1].cannonjs.quaternion),GAME_.zoomOut.enable&&(cameraPos.size-=.02,u(),GAME_.zoomOut.frames++,GAME_.zoomOut.frames>=GAME_.zoomOut.framesMax)&&(GAME_.zoomOut.enable=!1,GAME_.zoomOut.frames=0,GAME_.zoomOut.finished=!0)):(t=(e=stackBoxArr[stackBoxArr.length-1]).positive?.15:-.15,e.threejs.position[e.direction]>=boxSize.range-5&&(e.positive=!1),e.threejs.position[e.direction]<=-(boxSize.range-5)&&(e.positive=!0),e.threejs.position[e.direction]+=t,e.cannonjs.position[e.direction]+=t,camera.position.y{e.threejs.position.copy(e.cannonjs.position),e.threejs.quaternion.copy(e.cannonjs.quaternion)}),renderer.render(scene,camera),GAME_.screenshot.enable&&(GAME_.screenshot.frames>=GAME_.screenshot.framesMax?GAME_.zoomOut.finished&&(DrawCanvasCopy(renderer.domElement,e=>{e.fillStyle="rgba(0, 0, 0, 0.2)",e.fillRect(0,0,e.canvas.width,e.canvas.height),e.fillStyle="#ffffff",e.font="32px monospace";var t="NEW RECORD",o=e.measureText(t).width;e.fillText(t,e.canvas.width/2-o/2,e.canvas.height/2-100),e.font="bold 64px monospace",t=GAME_.score,o=e.measureText(t).width,e.fillText(t,e.canvas.width/2-o/2,e.canvas.height/2+50),GAME_.botMode&&(e.save(),e.translate(e.canvas.width/2,e.canvas.height/2+50),e.rotate(-Math.PI/8),e.fillStyle="rgba(255, 0, 0, 0.6)",e.font="bold 64px monospace",o=e.measureText(t="FAKE").width,e.fillText(t,-o/2,0),e.strokeStyle="rgba(255, 0, 0, 0.5)",e.lineWidth=5,e.strokeRect(-(o/2+10),-51.152,o+20,56.152),e.restore())},e=>{var t=document.createElement("img");const o=URL.createObjectURL(e);t.onload=()=>{URL.revokeObjectURL(o)},t.src=o,GAME_.screenshot.blob=e,GAME_.screenshot.callback(t)}),GAME_.screenshot.enable=!1,GAME_.screenshot.frames=0):GAME_.screenshot.frames++)}function _(){requestAnimationFrame(_),GAME_.fpsCtrl.now=w(),GAME_.fpsCtrl.elapsed=GAME_.fpsCtrl.now-GAME_.fpsCtrl.then,GAME_.fpsCtrl.elapsed>GAME_.fpsCtrl.fpsInterval&&(GAME_.fpsCtrl.mFps=Math.round(1e3/GAME_.fpsCtrl.elapsed)-(GAME_.fpsCtrl.forceLag?30:0),GAME_.fpsCtrl.mFps=GAME_.fpsCtrl.lagWarning.framesMax?(GAME_.fpsCtrl.lagWarning.lastWarning+3e4{var e,t,o,r,n,s,a,i;GAME_.status?(o=stackBoxArr[stackBoxArr.length-1],n=stackBoxArr[stackBoxArr.length-2],r=o.direction,n=o.threejs.position[r]-n.threejs.position[r],i=Math.abs(n),0<(s=(a="x"===r?o.width:o.depth)-i)?(a=s/a,i<.2?([9,19,29,39,49].includes(GAME_.combo)&&(h.classList.add("active"),setTimeout(()=>{h.classList.remove("active")},1100),GAME_.score+=10),GAME_.combo+=1,m.innerHTML="x"+GAME_.combo,m.classList.add("open"),setTimeout(()=>{m.classList.remove("open")},700)):GAME_.combo&&(GAME_.combo=0),e="x"===r?s:o.width,t="z"===r?s:o.depth,o.width=e,o.depth=t,o.threejs.scale[r]=a,o.threejs.position[r]-=n/2,o.cannonjs.position[r]-=n/2,a=new CANNON.Box(new CANNON.Vec3(e/2,boxSize.y/2,t/2)),o.cannonjs.shapes=[],o.cannonjs.addShape(a),.01<=i&&(a=Math.sign(n)*(s/2+i/2),n={x:"x"===r?o.threejs.position.x+a:o.threejs.position.x,z:"z"===r?o.threejs.position.z+a:o.threejs.position.z,width:"x"===r?i:e,depth:"z"===r?i:t},s=n.z,a=n.width,i=n.depth,n=E(n=n.x,boxSize.y*(stackBoxArr.length-1),s,a,i,!0),outBoxArr.push(n)),M("x"===r?o.threejs.position.x:-(boxSize.range-1),"z"===r?o.threejs.position.z:-(boxSize.range-1),e,t,"x"===r?"z":"x"),GAME_.score++,g(GAME_.score)):(GAME_.end=!0,world.remove(o.cannonjs),s=new CANNON.Box(new CANNON.Vec3(o.width/2,boxSize.y/2,o.depth/2)),(a=new CANNON.Body({mass:5,shape:s})).position.set(o.threejs.position.x,o.threejs.position.y,o.threejs.position.z),world.addBody(a),o.cannonjs=a,c.classList.toggle("disable"),l.classList.toggle("active"),GAME_.status=!1,GAME_.score>GAME_.bestResult&&(playConfetti(GAME_.confetti.range[0],GAME_.confetti.range[1]),GAME_.botMode||(GAME_.bestResult=GAME_.score,window.localStorage.setItem("bestResult",GAME_.score)),d.classList.add("new"),GAME_.newRecord=!0,GAME_.screenshot.service)&&(GAME_.screenshot.callback=e=>{p.replaceChild(e,p.querySelector("img")),p.classList.add("display")},GAME_.screenshot.enable=!0),GAME_.zoomOut.service&&(GAME_.zoomOut.enable=!0),i=localStorage.getItem("installDismissed")??!1,!enableDownload||"false"!=i&&i||(document.querySelector("#pwa-install").classList.add("display"),0{scene.remove(e.threejs),e.geometry.dispose(),e.material.dispose(),world.removeBody(e.cannonjs)}),outBoxArr.forEach(e=>{scene.remove(e.threejs),e.geometry.dispose(),e.material.dispose(),world.removeBody(e.cannonjs)}),stackBoxArr=[],outBoxArr=[],GAME_.score=0,GAME_.combo=0,A(),M(0,0,boxSize.x,boxSize.z,"x"),document.querySelector("#pwa-install").classList.remove("display"),p.classList.remove("display"),document.querySelector("#noti-popup").classList.remove("display")):(GAME_.fpsCtrl.fps=GAME_.fpsCtrl.forceLag?GAME_.fpsCtrl.fps/2:GAME_.fpsCtrl.fps,GAME_.fpsCtrl.fpsInterval=1e3/GAME_.fpsCtrl.fps,GAME_.fpsCtrl.then=w(),_(),GAME_.active=!0,d.querySelector(".score").innerHTML="SCORE"),g(GAME_.score),M(0,0,boxSize.x,boxSize.z,"z"),c.classList.toggle("disable"),l.classList.toggle("active"),GAME_.newRecord&&(GAME_.newRecord=!1,d.classList.remove("new")),GAME_.status=!0,GAME_.end=!1),A(hslDark=GAME_.end)};o="ontouchstart"in window||navigator.msMaxTouchPoints?"touchstart":"mousedown";e.addEventListener(o,fncStart);let n=!0;window.addEventListener("keydown",function(e){32!==e.keyCode&&40!==e.keyCode&&" "!==e.key||(e.preventDefault(),n&&(n=!1,fncStart()))}),window.addEventListener("keyup",function(e){32!==e.keyCode&&40!==e.keyCode&&" "!==e.key||(n=!0)}),window.addEventListener("resize",e=>{cameraPos.height=c_width*(window.innerHeight/window.innerWidth),cameraPos.size=700{await Blob2Share(GAME_.screenshot.blob)||t("Unable to share. Take screenshot 📸")})}); \ No newline at end of file