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

53 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,
2016-11-17 10:09:54 +01:00
renderer
2016-10-14 12:32:53 +02:00
) {
for(var s in this.scenes) {
var scene = this.scenes[s];
2016-11-23 13:01:24 +01:00
scene.render(dt, renderer, scene.cameras[scene.activeCameraIndex]);
}
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!
2016-11-21 08:20:47 +01:00
world.step(fixedDt, dt);
2016-10-14 12:32:53 +02:00
}
scene.update(dt);
scene.lateUpdate(dt);
2016-10-14 12:32:53 +02:00
}
};