2014-05-24 00:22:53 +00:00
|
|
|
// In each generator function you need a few things
|
|
|
|
// Something defining when the next block is being generated
|
|
|
|
// Something defining which and when the next function is going to be passed
|
|
|
|
|
|
|
|
function waveGen(clock) {
|
2014-05-22 19:29:35 +00:00
|
|
|
this.lastGen = Date.now();
|
2014-05-24 00:22:53 +00:00
|
|
|
this.nextGen = 1500; // - 1500; //delay before starting
|
|
|
|
this.start = Date.now();
|
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-05-24 00:22:53 +00:00
|
|
|
this.difficulty = 0;
|
|
|
|
|
2014-05-22 19:29:35 +00:00
|
|
|
this.update = function() {
|
2014-05-24 00:22:53 +00:00
|
|
|
if (this.difficulty < 15) {
|
2014-05-24 00:49:57 +00:00
|
|
|
if (this.difficulty < 8) {
|
|
|
|
this.difficulty = Math.floor((Date.now() - this.start)/5000); // every 5 seconds raise the difficulty
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.difficulty = Math.floor((Date.now() - this.start)/10000 + 3);
|
|
|
|
}
|
2014-05-24 00:22:53 +00:00
|
|
|
}
|
2014-05-24 00:49:57 +00:00
|
|
|
|
2014-05-24 00:22:53 +00:00
|
|
|
this.currentFunction();
|
|
|
|
};
|
|
|
|
|
|
|
|
this.randomGeneration = function() {
|
2014-05-22 19:29:35 +00:00
|
|
|
var now = Date.now();
|
|
|
|
if (now - this.lastGen > this.nextGen) {
|
2014-05-24 00:22:53 +00:00
|
|
|
this.lastGen = now;
|
2014-05-24 00:49:57 +00:00
|
|
|
if (this.nextGen > 1000) {
|
|
|
|
if (this.difficulty < 8) {
|
|
|
|
this.nextGen -= 15 * ((this.nextGen)/1100);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
this.nextGen -= 5 * ((this.nextGen)/1100);
|
|
|
|
}
|
|
|
|
if (this.difficulty)
|
|
|
|
console.log(this.nextGen);
|
2014-05-22 19:29:35 +00:00
|
|
|
}
|
2014-05-23 00:22:20 +00:00
|
|
|
var fv = randInt(0, 6);
|
2014-05-24 00:49:57 +00:00
|
|
|
addNewBlock(fv, colors[randInt(0, colors.length)], 1.5 + (this.difficulty/15) * 3);
|
2014-05-24 00:22:53 +00:00
|
|
|
|
|
|
|
// var nextPattern = randInt(0, 6)
|
|
|
|
// if () {
|
|
|
|
// this.currentFunction = this.
|
|
|
|
// }
|
2014-05-22 19:29:35 +00:00
|
|
|
}
|
2014-05-24 00:22:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// rest of generation functions
|
|
|
|
|
|
|
|
this.currentFunction = this.randomGeneration;
|
|
|
|
}
|
|
|
|
|
|
|
|
function generatorFunction() {
|
|
|
|
|
2014-05-22 19:29:35 +00:00
|
|
|
}
|
2014-05-24 00:22:53 +00:00
|
|
|
|
|
|
|
// In each generator function you need a few things
|
|
|
|
// Something defining when the next block is being generated
|
|
|
|
// Something defining which and when the next function is going to be passed
|