Path: blob/main/public/games/files/hextris/js/comboTimer.js
1036 views
function drawTimer() {1if(gameState==1){2var leftVertexes = [];3var rightVertexes = [];4if(MainHex.ct - MainHex.lastCombo < settings.comboTime){5for(var i=0;i<6;i++){6var done = (MainHex.ct -MainHex.lastCombo);7if(done<(settings.comboTime)*(5-i)*(1/6)){8leftVertexes.push(calcSide(i,i+1,1,1));9rightVertexes.push(calcSide(12-i,11-i,1,1));10}11else{12leftVertexes.push(calcSide(i,i+1,1-((done*6)/settings.comboTime)%(1),1));13rightVertexes.push(calcSide(12-i,11-i,1-((done*6)/settings.comboTime)%(1),1));14break;15}16}17}18if(rightVertexes.length !== 0) drawSide(rightVertexes);19if(leftVertexes.length !== 0) drawSide(leftVertexes);20}21}2223function calcSide(startVertex,endVertex,fraction,offset){24startVertex = (startVertex+offset)%12;25endVertex = (endVertex+offset)%12;26ctx.globalAlpha=1;27ctx.beginPath();28ctx.lineCap = "round";2930var radius = (settings.rows * settings.blockHeight) * (2/Math.sqrt(3)) + settings.hexWidth ;31var halfRadius = radius/2;32var triHeight = radius *(Math.sqrt(3)/2);33var Vertexes =[34[(halfRadius*3)/2,triHeight/2],35[radius,0],36[(halfRadius*3)/2,-triHeight/2],37[halfRadius,-triHeight],38[0,-triHeight],39[-halfRadius,-triHeight],40[-(halfRadius*3)/2,-triHeight/2],41[-radius,0],42[-(halfRadius*3)/2,triHeight/2],43[-halfRadius,triHeight],44[0,triHeight],45[halfRadius,triHeight]46].reverse();47var startX =trueCanvas.width/2 + Vertexes[startVertex][0];48var startY =trueCanvas.height/2 + Vertexes[startVertex][1];49var endX = trueCanvas.width/2 + Vertexes[endVertex][0];50var endY = trueCanvas.height/2 + Vertexes[endVertex][1];51return [[startX,startY],[((endX-startX)*fraction)+startX,((endY-startY)*fraction)+startY]];52}53function drawSide(vertexes){54if (gameState === 0) {55ctx.strokeStyle = hexColorsToTintedColors[MainHex.lastColorScored];56} else {57ctx.strokeStyle = MainHex.lastColorScored;58}59ctx.lineWidth =4*settings.scale;60ctx.moveTo(vertexes[0][0][0],vertexes[0][0][1]);61ctx.lineTo(vertexes[0][1][0],vertexes[0][1][1]);62for(var i=1;i<vertexes.length;i++){63ctx.lineTo(vertexes[i][1][0],vertexes[i][1][1]);64ctx.moveTo(vertexes[i][1][0],vertexes[i][1][1]);65}66ctx.closePath();67ctx.fill();68ctx.stroke();6970}717273