2014-06-01 01:43:12 +00:00
|
|
|
function blockDestroyed() {
|
2014-06-01 01:56:52 +00:00
|
|
|
if (waveone.nextGen > 1000) {
|
2014-06-01 02:32:02 +00:00
|
|
|
waveone.nextGen -= 10;
|
2014-06-01 01:43:12 +00:00
|
|
|
} else {
|
2014-06-01 01:56:52 +00:00
|
|
|
waveone.nextGen = 1000;
|
2014-06-01 01:43:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (waveone.difficulty < 15) {
|
2014-06-01 01:54:23 +00:00
|
|
|
waveone.difficulty += 0.04;
|
2014-06-01 01:43:12 +00:00
|
|
|
} else {
|
|
|
|
waveone.difficulty = 15;
|
|
|
|
}
|
|
|
|
}
|
2014-05-24 00:22:53 +00:00
|
|
|
|
|
|
|
function waveGen(clock) {
|
2014-05-24 16:09:46 +00:00
|
|
|
this.lastGen = 0;
|
|
|
|
this.last = 0;
|
2014-06-22 16:49:27 +00:00
|
|
|
this.nextGen = 2000; // - 1500; //delay before starting
|
2014-05-24 16:09:46 +00:00
|
|
|
this.start = 0;
|
2014-05-22 19:29:35 +00:00
|
|
|
this.colors = colors;
|
2014-05-24 00:49:57 +00:00
|
|
|
this.ct = 0;
|
2014-05-22 19:29:35 +00:00
|
|
|
this.clock = clock;
|
2014-06-22 16:49:27 +00:00
|
|
|
this.difficulty = 1;
|
2014-05-24 16:09:46 +00:00
|
|
|
this.dt = 0;
|
2014-05-22 19:29:35 +00:00
|
|
|
this.update = function() {
|
2014-05-24 16:09:46 +00:00
|
|
|
this.currentFunction();
|
2014-05-31 19:32:01 +00:00
|
|
|
this.dt += 16.6666667 * spaceModifier;
|
2014-05-24 16:21:29 +00:00
|
|
|
this.computeDifficulty();
|
2014-05-25 22:45:20 +00:00
|
|
|
if (this.dt - this.lastGen * (1/settings.creationSpeedModifier) > this.nextGen) {
|
2014-06-01 01:56:52 +00:00
|
|
|
if (this.nextGen > 1000) {
|
2014-06-22 16:49:27 +00:00
|
|
|
this.nextGen -= (0.7 * (this.nextGen/1300)) * settings.creationSpeedModifier;
|
2014-05-24 16:21:29 +00:00
|
|
|
}
|
|
|
|
}
|
2014-05-24 23:50:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
this.randomGeneration = function() {
|
2014-05-24 16:09:46 +00:00
|
|
|
if (this.dt - this.lastGen > this.nextGen) {
|
2014-05-24 02:41:55 +00:00
|
|
|
this.ct++;
|
2014-05-24 16:09:46 +00:00
|
|
|
this.lastGen = this.dt;
|
2014-05-24 02:46:01 +00:00
|
|
|
var fv = randInt(0, MainClock.sides);
|
2014-06-01 22:48:28 +00:00
|
|
|
addNewBlock(fv, colors[randInt(0, colors.length)], 1.6 + (this.difficulty/15) * 3);
|
2014-05-25 01:12:05 +00:00
|
|
|
if (this.ct > 7) {
|
2014-05-24 18:15:07 +00:00
|
|
|
var nextPattern = randInt(0, 20 + 4);
|
|
|
|
if (nextPattern > 4 + 17) {
|
|
|
|
this.ct = 0;
|
|
|
|
this.currentFunction = this.doubleGeneration;
|
|
|
|
} else if (nextPattern > 4 + 14) {
|
|
|
|
this.ct = 0;
|
|
|
|
this.currentFunction = this.crosswiseGeneration;
|
|
|
|
} else if (nextPattern > 4 + 11) {
|
|
|
|
this.ct = 0;
|
|
|
|
this.currentFunction = this.spiralGeneration;
|
|
|
|
}
|
|
|
|
else if (nextPattern > 4 + 8) {
|
2014-05-24 02:41:55 +00:00
|
|
|
this.ct = 0;
|
|
|
|
this.currentFunction = this.circleGeneration;
|
2014-05-24 18:15:07 +00:00
|
|
|
}
|
2014-05-22 19:29:35 +00:00
|
|
|
}
|
2014-05-24 00:22:53 +00:00
|
|
|
|
2014-05-22 19:29:35 +00:00
|
|
|
}
|
2014-05-24 00:22:53 +00:00
|
|
|
};
|
|
|
|
|
2014-05-24 02:41:55 +00:00
|
|
|
this.computeDifficulty = function() {
|
2014-06-01 01:43:12 +00:00
|
|
|
if (this.difficulty < 15) {
|
2014-05-24 02:41:55 +00:00
|
|
|
if (this.difficulty < 8) {
|
2014-06-01 01:54:23 +00:00
|
|
|
this.difficulty += (this.dt - this.last)/(2000000);
|
2014-05-24 02:41:55 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-06-01 01:54:23 +00:00
|
|
|
this.difficulty += (this.dt - this.last)/(40000000);
|
2014-05-24 02:41:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.circleGeneration = function() {
|
2014-05-24 16:09:46 +00:00
|
|
|
if (this.dt - this.lastGen > this.nextGen + 500) {
|
2014-05-24 17:56:41 +00:00
|
|
|
var numColors = randInt(1, 4);
|
2014-05-24 02:41:55 +00:00
|
|
|
if (numColors == 3) {
|
2014-05-24 17:56:41 +00:00
|
|
|
numColors = randInt(1, 4);
|
2014-05-24 02:41:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var colorList = [];
|
|
|
|
nextLoop:
|
|
|
|
for (var i = 0; i < numColors; i++) {
|
|
|
|
var q = randInt(0, colors.length);
|
|
|
|
for (var j in colorList) {
|
|
|
|
if (colorList[j] == colors[q]) {
|
|
|
|
i--;
|
|
|
|
continue nextLoop;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
colorList.push(colors[q]);
|
|
|
|
}
|
|
|
|
|
2014-05-24 02:46:01 +00:00
|
|
|
for (var i = 0; i < MainClock.sides; i++) {
|
2014-06-01 22:48:28 +00:00
|
|
|
addNewBlock(i, colorList[i % numColors], 1.5 + (this.difficulty/15) * 3);
|
2014-05-24 02:41:55 +00:00
|
|
|
}
|
2014-05-24 18:12:01 +00:00
|
|
|
|
2014-05-24 02:41:55 +00:00
|
|
|
this.ct += 15;
|
2014-05-24 16:09:46 +00:00
|
|
|
this.lastGen = this.dt;
|
2014-05-25 01:12:05 +00:00
|
|
|
this.shouldChangePattern(1);
|
2014-05-24 02:41:55 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.crosswiseGeneration = function() {
|
2014-05-24 23:50:57 +00:00
|
|
|
if (this.dt - this.lastGen > this.nextGen) {
|
2014-05-24 02:41:55 +00:00
|
|
|
var ri = randInt(0, colors.length);
|
|
|
|
var i = randInt(0, colors.length);
|
2014-06-01 22:48:28 +00:00
|
|
|
addNewBlock(i, colors[ri], 0.6 + (this.difficulty/15) * 3);
|
|
|
|
addNewBlock((i + 3) % MainClock.sides, colors[ri], 0.6 + (this.difficulty/15) * 3);
|
2014-05-24 02:41:55 +00:00
|
|
|
this.ct += 1.5;
|
2014-05-24 16:09:46 +00:00
|
|
|
this.lastGen = this.dt;
|
2014-05-25 01:12:05 +00:00
|
|
|
this.shouldChangePattern();
|
2014-05-24 02:41:55 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.spiralGeneration = function() {
|
2014-05-25 01:12:05 +00:00
|
|
|
var dir = randInt(0, 2);
|
|
|
|
if (this.dt - this.lastGen > this.nextGen * (5/9)) {
|
|
|
|
if (dir) {
|
2014-06-01 22:48:28 +00:00
|
|
|
addNewBlock(5 - (this.ct % MainClock.sides), colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * (3/2));
|
2014-05-25 01:12:05 +00:00
|
|
|
}
|
|
|
|
else {
|
2014-06-01 22:48:28 +00:00
|
|
|
addNewBlock(this.ct % MainClock.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * (3/2));
|
2014-05-25 01:12:05 +00:00
|
|
|
}
|
2014-05-24 02:41:55 +00:00
|
|
|
this.ct += 1;
|
2014-05-24 16:09:46 +00:00
|
|
|
this.lastGen = this.dt;
|
2014-05-25 01:12:05 +00:00
|
|
|
this.shouldChangePattern();
|
2014-05-24 02:41:55 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.doubleGeneration = function() {
|
2014-05-24 16:09:46 +00:00
|
|
|
if (this.dt - this.lastGen > this.nextGen) {
|
2014-05-24 02:41:55 +00:00
|
|
|
var i = randInt(0, colors.length);
|
2014-06-01 22:48:28 +00:00
|
|
|
addNewBlock(i, colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * 3);
|
|
|
|
addNewBlock((i + 1) % MainClock.sides, colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * 3);
|
2014-05-24 02:41:55 +00:00
|
|
|
this.ct += 2;
|
2014-05-24 16:09:46 +00:00
|
|
|
this.lastGen = this.dt;
|
2014-05-25 01:12:05 +00:00
|
|
|
this.shouldChangePattern();
|
2014-05-24 02:41:55 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
this.setRandom = function() {
|
|
|
|
this.ct = 0;
|
|
|
|
this.currentFunction = this.randomGeneration;
|
|
|
|
};
|
|
|
|
|
2014-05-25 01:12:05 +00:00
|
|
|
this.shouldChangePattern = function(x) {
|
|
|
|
if (x) {
|
|
|
|
var q = randInt(0, 4);
|
|
|
|
this.ct = 0;
|
|
|
|
switch (q) {
|
|
|
|
case 0:
|
|
|
|
this.currentFunction = this.doubleGeneration;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
this.currentFunction = this.spiralGeneration;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
this.currentFunction = this.crosswiseGeneration;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (this.ct > 8) {
|
2014-05-24 02:41:55 +00:00
|
|
|
if (randInt(0, 2) === 0) {
|
|
|
|
this.setRandom();
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
};
|
|
|
|
|
2014-05-24 00:22:53 +00:00
|
|
|
// rest of generation functions
|
|
|
|
|
|
|
|
this.currentFunction = this.randomGeneration;
|
2014-06-01 01:43:12 +00:00
|
|
|
}
|