2016-10-14 12:32:53 +02:00
|
|
|
GameLib.D3.Game = function (
|
|
|
|
|
|
|
|
) {
|
|
|
|
this.scenes = {};
|
|
|
|
};
|
|
|
|
|
2016-11-01 12:42:06 +01:00
|
|
|
GameLib.D3.Game.prototype.addScene = function(
|
|
|
|
scene,
|
|
|
|
identifer
|
2016-10-14 12:32:53 +02:00
|
|
|
) {
|
2016-11-01 12:42:06 +01:00
|
|
|
this.scenes[identifer] = scene;
|
2016-10-14 12:32:53 +02:00
|
|
|
};
|
|
|
|
|
2016-11-01 12:42:06 +01:00
|
|
|
GameLib.D3.Game.prototype.processPhysics = function (
|
2016-11-01 16:32:06 +01:00
|
|
|
dt
|
2016-10-14 12:32:53 +02:00
|
|
|
) {
|
2016-11-01 12:42:06 +01:00
|
|
|
for(var s in this.scenes) {
|
|
|
|
var scene = this.scenes[s];
|
2016-10-14 12:32:53 +02:00
|
|
|
|
2016-11-01 12:42:06 +01:00
|
|
|
for(var w in scene.worlds) {
|
|
|
|
var world = scene.worlds[w];
|
2016-11-01 16:32:06 +01:00
|
|
|
world.step(dt);
|
2016-11-01 12:42:06 +01:00
|
|
|
}
|
|
|
|
}
|
2016-10-14 12:32:53 +02:00
|
|
|
};
|
|
|
|
|
2016-11-01 12:42:06 +01:00
|
|
|
GameLib.D3.Game.prototype.render = function(
|
|
|
|
dt,
|
|
|
|
renderer,
|
|
|
|
camera
|
2016-10-14 12:32:53 +02:00
|
|
|
) {
|
2016-11-01 12:42:06 +01:00
|
|
|
for(var s in this.scenes) {
|
|
|
|
var scene = this.scenes[s];
|
2016-11-11 16:25:39 +01:00
|
|
|
scene.render(dt, renderer, scene.camera);
|
2016-11-01 12:42:06 +01:00
|
|
|
}
|
2016-10-14 12:32:53 +02:00
|
|
|
};
|
|
|
|
|
2016-11-01 12:42:06 +01:00
|
|
|
GameLib.D3.Game.prototype.update = function(
|
2016-11-01 16:32:06 +01:00
|
|
|
dt,
|
|
|
|
fixedDt
|
2016-10-14 12:32:53 +02:00
|
|
|
) {
|
2016-11-01 12:42:06 +01:00
|
|
|
for(var s in this.scenes) {
|
2016-10-14 12:32:53 +02:00
|
|
|
var scene = this.scenes[s];
|
|
|
|
|
2016-11-01 12:42:06 +01:00
|
|
|
for(var w in scene.worlds) {
|
|
|
|
var world = scene.worlds[w];
|
2016-11-08 11:13:55 +01:00
|
|
|
// NOTE: We are calling the step function with a variable timestep!
|
|
|
|
world.step(dt);
|
2016-10-14 12:32:53 +02:00
|
|
|
}
|
|
|
|
|
2016-11-01 12:42:06 +01:00
|
|
|
scene.update(dt);
|
|
|
|
scene.lateUpdate(dt);
|
2016-10-14 12:32:53 +02:00
|
|
|
}
|
|
|
|
};
|