From 9f1e6aaca2b5f2fc0822fb4d33f8c01b0f4f8ef0 Mon Sep 17 00:00:00 2001 From: garrettdreyfus Date: Tue, 20 May 2014 17:09:39 -0400 Subject: [PATCH 1/5] no diagonals for real --- js/checking.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/checking.js b/js/checking.js index d11c4ab..dd05275 100644 --- a/js/checking.js +++ b/js/checking.js @@ -12,7 +12,7 @@ function floodFill(clock,side,index) { var color = clock.blocks[side][index].color; for(var x =-1;x<2;x++){ for(var y =-1;y<2;y++){ - if(x==y){continue;} + if(Math.abs(x)==Math.abs(y)){continue;} if(clock.blocks[(side+x+clock.sides)%clock.sides] === undefined){continue;} if(clock.blocks[(side+x+clock.sides)%clock.sides][index+y] !== undefined){ if(clock.blocks[(side+x+clock.sides)%clock.sides][index+y].color== color && search(deleting,[(side+x+clock.sides)%clock.sides,index+y]) == false){ From 82415e40543cdf2de6adfd8d917fc421a1257b71 Mon Sep 17 00:00:00 2001 From: Garrett Finucane Date: Tue, 20 May 2014 19:56:58 -0400 Subject: [PATCH 2/5] Delete hey.js --- js/hey.js | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 js/hey.js diff --git a/js/hey.js b/js/hey.js deleted file mode 100644 index ab926b3..0000000 --- a/js/hey.js +++ /dev/null @@ -1,24 +0,0 @@ -floodFill.deleted = []; -function floodFill(clock,side,index) { - if(clock.blocks[side] !== undefined){return;} - if(clock.blocks[side][index] !== undefined){return;} - var color = clock.blocks[side][index].color; - var arrX = [-1,0,1]; - var arrY = [-1,0,1]; - for( X in arrX){ - for(Y in arrY){ - var x = arrX[X]; - var y = arrY[Y]; - if(x==0 && y==0){return;} - if(clock.blocks[(side+x+clock.sides)%clock.sides][index+y] !== undefined){ - if(clock.blocks[(side+x+clock.sides)%clock.sides][index+y].color== color && floodFill.deleted.indexOf([side+x,index+y]) == -1){ - deleted.push([(side+x+clock.sides)%clock.sides,index+y]); - floodFill(clock,(side+x+clock.sides)%clock.sides,index+y); - - } - } - } - } - - -} From af6c0b13807a832dab673abbba9462e7e41eafe5 Mon Sep 17 00:00:00 2001 From: Noah Moroze Date: Tue, 20 May 2014 20:33:44 -0400 Subject: [PATCH 3/5] Render score on canvas for better performance --- index.html | 1 - js/main.js | 4 +++- js/view.js | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 39046ec..92a1422 100644 --- a/index.html +++ b/index.html @@ -20,7 +20,6 @@

Hextris

- 0 (x1)
diff --git a/js/main.js b/js/main.js index fafaaea..00104ca 100644 --- a/js/main.js +++ b/js/main.js @@ -95,10 +95,12 @@ function update() { } function render() { - document.getElementById("score").innerHTML = score + " (x" + scoreScalar * scoreAdditionCoeff + ")"; + // document.getElementById("score").innerHTML =; ctx.clearRect(0, 0, canvas.originalWidth, canvas.originalHeight); clearGameBoard(); + + renderText(score + " (x" + scoreScalar * scoreAdditionCoeff + ")", canvas.originalWidth/2, canvas.originalHeight/2 - 350); var i; for (i in MainClock.blocks) { diff --git a/js/view.js b/js/view.js index 4310b46..0bfc20c 100644 --- a/js/view.js +++ b/js/view.js @@ -18,6 +18,23 @@ function showModal(text, secondaryText) { ctx.fillText(secondaryText, canvas.originalWidth / 2, canvas.originalHeight / 2 + fontSizeLarge / 4 + fontSizeSmall / 4 + 30); } +function renderText(lines, x, y, fontSize) { + if(typeof lines == 'string' || lines instanceof String) { + lines = [lines]; + } + + var fontSize = fontSize || 50; + + ctx.font = fontSize + 'px Roboto'; // figure out what is not working + ctx.textAlign = 'center'; + ctx.fillStyle = 'white'; + + for(var i=0; i Date: Tue, 20 May 2014 20:39:19 -0400 Subject: [PATCH 4/5] Got rid of extraneous debugger call --- js/checking.js | 2 +- js/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js/checking.js b/js/checking.js index dd05275..0b63d48 100644 --- a/js/checking.js +++ b/js/checking.js @@ -28,7 +28,7 @@ function consolidateBlocks(clock,side,index){ deleting=[]; deleting.push([side,index]); floodFill(clock,side,index); - debugger; + var deleteList= deleting; if(deleteList.length<3){return;} for(i in deleteList){ diff --git a/js/main.js b/js/main.js index 00104ca..c117456 100644 --- a/js/main.js +++ b/js/main.js @@ -100,7 +100,7 @@ function render() { ctx.clearRect(0, 0, canvas.originalWidth, canvas.originalHeight); clearGameBoard(); - renderText(score + " (x" + scoreScalar * scoreAdditionCoeff + ")", canvas.originalWidth/2, canvas.originalHeight/2 - 350); + renderText(score + " (x" + scoreScalar * scoreAdditionCoeff + ")", canvas.originalWidth/2, canvas.originalHeight/2 - 360); var i; for (i in MainClock.blocks) { From 8219515329e0f1a7b96013c878424e55121d11bb Mon Sep 17 00:00:00 2001 From: garrettdreyfus Date: Tue, 20 May 2014 22:33:50 -0400 Subject: [PATCH 5/5] NO LAG ctx.shadowBlur=25 --- js/view.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/view.js b/js/view.js index 0bfc20c..f299198 100644 --- a/js/view.js +++ b/js/view.js @@ -44,7 +44,7 @@ function clearShadows() { function clearGameBoard() { ctx.shadowColor = '#2980b9'; - ctx.shadowBlur = 25; + //ctx.shadowBlur = 25; drawPolygon(canvas.originalWidth / 2, canvas.originalHeight / 2, 6, canvas.originalWidth / 2 - 25, 30, hexagonBackgroundColor); clearShadows(); } @@ -83,4 +83,4 @@ function drawPolygon(x, y, sides, radius, theta, color, fill) { // can make more } else { ctx.stroke(); } -}; \ No newline at end of file +};