54 lines
1.0 KiB
JavaScript
54 lines
1.0 KiB
JavaScript
GameLib.D3.Game = function (
|
|
|
|
) {
|
|
this.scenes = {};
|
|
};
|
|
|
|
GameLib.D3.Game.prototype.addScene = function(
|
|
scene,
|
|
identifer
|
|
) {
|
|
this.scenes[identifer] = scene;
|
|
};
|
|
|
|
GameLib.D3.Game.prototype.processPhysics = function (
|
|
dt
|
|
) {
|
|
for(var s in this.scenes) {
|
|
var scene = this.scenes[s];
|
|
|
|
for(var w in scene.worlds) {
|
|
var world = scene.worlds[w];
|
|
world.step(dt);
|
|
}
|
|
}
|
|
};
|
|
|
|
GameLib.D3.Game.prototype.render = function(
|
|
dt,
|
|
renderer,
|
|
camera
|
|
) {
|
|
for(var s in this.scenes) {
|
|
var scene = this.scenes[s];
|
|
scene.render(dt, renderer, scene.camera);
|
|
}
|
|
};
|
|
|
|
GameLib.D3.Game.prototype.update = function(
|
|
dt,
|
|
fixedDt
|
|
) {
|
|
for(var s in this.scenes) {
|
|
var scene = this.scenes[s];
|
|
|
|
for(var w in scene.worlds) {
|
|
var world = scene.worlds[w];
|
|
// NOTE: We are calling the step function with a variable timestep!
|
|
world.step(dt);
|
|
}
|
|
|
|
scene.update(dt);
|
|
scene.lateUpdate(dt);
|
|
}
|
|
}; |