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

54 lines
1.0 KiB
JavaScript
Raw Normal View History

2016-10-14 12:32:53 +02:00
GameLib.D3.Game = function (
) {
this.scenes = {};
};
GameLib.D3.Game.prototype.addScene = function(
scene,
identifer
2016-10-14 12:32:53 +02:00
) {
this.scenes[identifer] = scene;
2016-10-14 12:32:53 +02:00
};
GameLib.D3.Game.prototype.processPhysics = function (
2016-11-01 16:32:06 +01:00
dt
2016-10-14 12:32:53 +02:00
) {
for(var s in this.scenes) {
var scene = this.scenes[s];
2016-10-14 12:32:53 +02:00
for(var w in scene.worlds) {
var world = scene.worlds[w];
2016-11-01 16:32:06 +01:00
world.step(dt);
}
}
2016-10-14 12:32:53 +02:00
};
GameLib.D3.Game.prototype.render = function(
dt,
renderer,
camera
2016-10-14 12:32:53 +02:00
) {
for(var s in this.scenes) {
var scene = this.scenes[s];
scene.render(dt, renderer, camera);
}
2016-10-14 12:32:53 +02: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
) {
for(var s in this.scenes) {
2016-10-14 12:32:53 +02:00
var scene = this.scenes[s];
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
}
scene.update(dt);
scene.lateUpdate(dt);
2016-10-14 12:32:53 +02:00
}
};