From 1cb8663496219aa9cff99e0ce4115cb804d5e86f Mon Sep 17 00:00:00 2001 From: Garrett Finucane Date: Fri, 30 May 2014 19:51:53 -0400 Subject: [PATCH] save state fixed. simultaneous checking works --- js/0 | 2 -- js/Block.js | 2 ++ js/Clock.js | 6 +++--- js/update.js | 8 ++++++++ 4 files changed, 13 insertions(+), 5 deletions(-) delete mode 100644 js/0 diff --git a/js/0 b/js/0 deleted file mode 100644 index 1750607..0000000 --- a/js/0 +++ /dev/null @@ -1,2 +0,0 @@ -Text.js:8: this.alive=1; -Text.js:11: if(this.alive>0){ diff --git a/js/Block.js b/js/Block.js index d4b6a02..9834501 100644 --- a/js/Block.js +++ b/js/Block.js @@ -4,6 +4,8 @@ function Block(fallingLane, color, iter, distFromHex, settled) { this.height = settings.blockHeight; //the lane which the block was shot from this.fallingLane = fallingLane; + + this.checked=0; //the angle at which the block falls this.angle = 90 - (30 + 60 * fallingLane); //for calculating the rotation of blocks attached to the center clock diff --git a/js/Clock.js b/js/Clock.js index e2696de..1583dcd 100644 --- a/js/Clock.js +++ b/js/Clock.js @@ -49,7 +49,7 @@ function Clock(sideLength) { block.distFromHex = MainClock.sideLength / 2 * Math.sqrt(3) + block.height * this.blocks[lane].length; this.blocks[lane].push(block); block.attachedLane = lane; - consolidateBlocks(this, lane, this.blocks[lane].length - 1); + block.checked=1; }; this.doesBlockCollide = function(block, position, tArr) { @@ -63,7 +63,7 @@ function Clock(sideLength) { if (block.distFromHex - block.iter * settings.scale - (this.sideLength / 2) * Math.sqrt(3) <= 0) { block.distFromHex = (this.sideLength / 2) * Math.sqrt(3); block.settled = 1; - consolidateBlocks(this, block.attachedLane, block.getIndex()); + block.checked=1; } else { block.settled = 0; } @@ -71,7 +71,7 @@ function Clock(sideLength) { if (arr[position - 1].settled && block.distFromHex - block.iter * settings.scale - arr[position - 1].distFromHex - arr[position - 1].height <= 0) { block.distFromHex = arr[position - 1].distFromHex + arr[position - 1].height; block.settled = 1; - consolidateBlocks(this, block.attachedLane, block.getIndex()); + block.checked=1; } else { block.settled = 0; diff --git a/js/update.js b/js/update.js index 8b3b865..1bba45e 100644 --- a/js/update.js +++ b/js/update.js @@ -33,6 +33,14 @@ function update() { } } + for (var i = 0; i < MainClock.blocks.length; i++) { + for (var j = 0; j < MainClock.blocks[i].length; j++) { + if(MainClock.blocks[i][j].checked ==1 ){ + consolidateBlocks(MainClock,MainClock.blocks[i][j].attachedLane,MainClock.blocks[i][j].getIndex()); + MainClock.blocks[i][j].checked=0; + } + } + } var lowestDeletedIndex; for (var i = 0; i < MainClock.blocks.length; i++) { lowestDeletedIndex = 99;