save state fixed. simultaneous checking works

This commit is contained in:
Garrett Finucane 2014-05-30 19:51:53 -04:00
parent 90ac4ac8e7
commit 1cb8663496
4 changed files with 13 additions and 5 deletions

2
js/0
View file

@ -1,2 +0,0 @@
Text.js:8: this.alive=1;
Text.js:11: if(this.alive>0){

View file

@ -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

View file

@ -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;

View file

@ -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;