diff --git a/checking.js b/checking.js index 722c65f..f06606d 100644 --- a/checking.js +++ b/checking.js @@ -66,7 +66,7 @@ function consolidateBlocks(clock,side,index) { deleted.push([]); } eraseBlocks(clock,deleted); - return + return; } function eraseBlocks(clock,deleted) { diff --git a/entities.js b/entities.js index 4aa6562..0e5c762 100644 --- a/entities.js +++ b/entities.js @@ -88,22 +88,34 @@ function Clock(sideLength) { if (position <= 0) { if (block.distFromHex - (this.sideLength/2) * Math.sqrt(3) <= 0) { block.settled = 1; + if (iter == 2 && block.distFromHex + 1 - (this.sideLength/2) * Math.sqrt(3) <= 0) { + block.distFromHex--; + } } } else { if (block.distFromHex + iter - arr[position - 1].distFromHex - arr[position - 1].height <= 0) { block.settled = 1; + if (iter == 2 && block.distFromHex + 1 + iter - arr[position - 1].distFromHex - arr[position - 1].height <= 0) { + block.distFromHex--; + } } } } else { if (arr.length > 0) { if (block.distFromHex + iter - arr[arr.length - 1].distFromHex - arr[arr.length - 1].height <= 0) { + if (iter == 2 && block.distFromHex + iter + 1 - arr[arr.length - 1].distFromHex - arr[arr.length - 1].height <= 0) { + block.distFromHex--; + } this.addBlock(block); } } else { if (block.distFromHex + iter - (this.sideLength/2) * Math.sqrt(3) <= 0) { + if (iter == 2 && block.distFromHex + iter + 1 - (this.sideLength/2) * Math.sqrt(3) <= 0) { + block.distFromHex--; + } this.addBlock(block); } } diff --git a/index.html b/index.html index dcceef0..b581af0 100644 --- a/index.html +++ b/index.html @@ -17,11 +17,11 @@ -

Hextris

+

Hextris

0 (x1)
- + diff --git a/input.js b/input.js index 0807461..016738f 100644 --- a/input.js +++ b/input.js @@ -16,3 +16,15 @@ keypress.register_combo({ } }, }); + +keypress.register_combo({ + keys: "space", + on_keyup: function(){ + iter = 1; + scoreAdditionCoeff = 1; + }, + on_keydown: function() { + iter = 2; + scoreAdditionCoeff = 2; + } +}); diff --git a/main.js b/main.js index 15ed9e2..246cde0 100644 --- a/main.js +++ b/main.js @@ -42,9 +42,10 @@ function init() { var colors = ["#e74c3c", "#f1c40f","#3498db"]; var hexagonBackgroundColor = '#ecf0f1'; var swegBlue = '#2c3e50'; //tumblr? +var scoreAdditionCoeff = 1; function render() { - document.getElementById("score").innerHTML = score + " (x"+scoreScalar+")"; + document.getElementById("score").innerHTML = score + " (x"+scoreScalar * scoreAdditionCoeff+")"; var now = Date.now(); if(now - lastGen > nextGen) { blocks.push(new Block(randInt(0, 6), colors[randInt(0, colors.length)])); @@ -52,7 +53,7 @@ function render() { nextGen = randInt(500/iter, 1500/iter); } if(now - prevScore > 1000) { - score += 5 * scoreScalar; + score += 5 * (scoreScalar * scoreAdditionCoeff); prevScore = now; iter += 0.1; }