Added control panel

This commit is contained in:
MaxRobinsonTheGreat
2020-07-08 19:32:05 -06:00
parent 2ba56abb1d
commit c6b0a5bafc
9 changed files with 176 additions and 37 deletions

View File

@@ -1,19 +1,26 @@
const Environment = require('./Environment');
const ControlPanel = require('./ControlPanel');
class Engine{
constructor(){
this.fps = 0;
this.environment = new Environment(5);
this.controlpanel = new ControlPanel(this);
this.environment.OriginOfLife();
this.last_update = Date.now();
this.delta_time = 0;
this.actual_fps = 0;
this.running = false;
}
start(fps=60) {
if (fps <= 0)
fps = 1;
if (fps > 500)
fps = 500;
this.fps = fps;
this.game_loop = setInterval(function(){this.update();}.bind(this), 1000/fps);
this.runnning = true;
this.running = true;
}
stop() {
@@ -27,6 +34,7 @@ class Engine{
this.last_update = Date.now();
this.environment.update(this.delta_time);
this.environment.render();
this.actual_fps = 1/this.delta_time*1000;
}
}