2014-05-26 01:49:03 +00:00
|
|
|
//remember to update history function to show the respective iter speeds
|
|
|
|
function update() {
|
2014-07-26 23:58:58 +00:00
|
|
|
var now = MainHex.ct;
|
2014-07-18 01:11:05 +00:00
|
|
|
if (gameState == 1) {
|
2014-05-26 01:49:03 +00:00
|
|
|
waveone.update();
|
|
|
|
if (now - waveone.prevTimeScored > 1000) {
|
|
|
|
waveone.prevTimeScored = now;
|
|
|
|
}
|
|
|
|
}
|
2014-06-01 22:48:28 +00:00
|
|
|
var lowestDeletedIndex = 99;
|
2014-06-01 01:43:12 +00:00
|
|
|
var i;
|
|
|
|
var j;
|
|
|
|
var block;
|
2014-05-26 01:49:03 +00:00
|
|
|
|
|
|
|
var objectsToRemove = [];
|
2014-06-01 22:48:28 +00:00
|
|
|
for (i = 0; i < blocks.length; i++) {
|
2014-07-04 16:42:44 +00:00
|
|
|
MainHex.doesBlockCollide(blocks[i]);
|
2014-05-26 01:49:03 +00:00
|
|
|
if (!blocks[i].settled) {
|
|
|
|
if (!blocks[i].initializing) blocks[i].distFromHex -= blocks[i].iter * settings.scale;
|
|
|
|
} else if (!blocks[i].removed) {
|
|
|
|
blocks[i].removed = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-04 16:42:44 +00:00
|
|
|
for (i = 0; i < MainHex.blocks.length; i++) {
|
|
|
|
for (j = 0; j < MainHex.blocks[i].length; j++) {
|
|
|
|
if (MainHex.blocks[i][j].checked ==1 ) {
|
|
|
|
consolidateBlocks(MainHex,MainHex.blocks[i][j].attachedLane,MainHex.blocks[i][j].getIndex());
|
|
|
|
MainHex.blocks[i][j].checked=0;
|
2014-06-01 22:48:28 +00:00
|
|
|
}
|
2014-05-30 23:51:53 +00:00
|
|
|
}
|
2014-06-01 22:48:28 +00:00
|
|
|
}
|
2014-06-01 01:43:12 +00:00
|
|
|
|
2014-07-04 16:42:44 +00:00
|
|
|
for (i = 0; i < MainHex.blocks.length; i++) {
|
2014-05-26 01:49:03 +00:00
|
|
|
lowestDeletedIndex = 99;
|
2014-07-04 16:42:44 +00:00
|
|
|
for (j = 0; j < MainHex.blocks[i].length; j++) {
|
|
|
|
block = MainHex.blocks[i][j];
|
2014-05-26 01:49:03 +00:00
|
|
|
if (block.deleted == 2) {
|
2014-07-04 16:42:44 +00:00
|
|
|
MainHex.blocks[i].splice(j,1);
|
2014-06-01 01:43:12 +00:00
|
|
|
blockDestroyed();
|
2014-05-26 01:49:03 +00:00
|
|
|
if (j < lowestDeletedIndex) lowestDeletedIndex = j;
|
|
|
|
j--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-04 16:42:44 +00:00
|
|
|
if (lowestDeletedIndex < MainHex.blocks[i].length) {
|
|
|
|
for (j = lowestDeletedIndex; j < MainHex.blocks[i].length; j++) {
|
|
|
|
MainHex.blocks[i][j].settled = 0;
|
2014-05-26 01:49:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-04 16:42:44 +00:00
|
|
|
for (i = 0; i < MainHex.blocks.length; i++) {
|
|
|
|
for (j = 0; j < MainHex.blocks[i].length; j++) {
|
|
|
|
block = MainHex.blocks[i][j];
|
|
|
|
MainHex.doesBlockCollide(block, j, MainHex.blocks[i]);
|
2014-05-26 01:49:03 +00:00
|
|
|
|
2014-07-04 16:42:44 +00:00
|
|
|
if (!MainHex.blocks[i][j].settled) {
|
|
|
|
MainHex.blocks[i][j].distFromHex -= block.iter * settings.scale;
|
2014-05-26 01:49:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-01 01:43:12 +00:00
|
|
|
for(i = 0; i < blocks.length;i++){
|
|
|
|
if (blocks[i].removed == 1) {
|
2014-05-26 01:49:03 +00:00
|
|
|
blocks.splice(i,1);
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
}
|
2014-08-18 03:58:17 +00:00
|
|
|
if(Date.now()-MainHex.lastUpdate>=17){
|
|
|
|
MainHex.ct++;
|
|
|
|
}
|
2014-05-26 01:49:03 +00:00
|
|
|
}
|