basic evolution finished

This commit is contained in:
MaxRobinsonTheGreat
2020-07-04 14:01:30 -06:00
parent 8d208ca9cc
commit 9b24e4cc1c
16 changed files with 2878 additions and 7 deletions

34
src/Engine.js Normal file
View File

@@ -0,0 +1,34 @@
const Environment = require('./Environment');
class Engine{
constructor(){
this.fps = 0;
this.environment = new Environment(5);
this.environment.OriginOfLife();
this.last_update = Date.now();
this.delta_time = 0;
this.running = false;
}
start(fps=60) {
this.fps = fps;
this.game_loop = setInterval(function(){this.update();}.bind(this), 1000/fps);
this.runnning = true;
}
stop() {
clearInterval(this.game_loop);
this.running = false;
}
update() {
this.delta_time = Date.now() - this.last_update;
this.last_update = Date.now();
this.environment.update(this.delta_time);
this.environment.render();
}
}
module.exports = Engine;