r3-legacy/src/game-lib-game.js

53 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
) {
for(var s in this.scenes) {
var scene = this.scenes[s];
scene.render(dt, renderer);
}
};
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(fixedDt, dt);
}
scene.update(dt);
scene.lateUpdate(dt);
}
};