added zoom for OrthographicCamera, tried to decouple gl rendering and box2d updates, didn't work yet

This commit is contained in:
Jeena 2013-12-02 16:13:53 +01:00
parent 1f55cdff2d
commit ffb7db528a
5 changed files with 50 additions and 44 deletions

View file

@ -21,6 +21,7 @@ function (Box2D, Parent, PhysicsEngine, ViewController, PlayerController, Notifi
this.me = null;
this.update();
this.render();
}
GameController.prototype = Object.create(Parent.prototype);
@ -54,16 +55,20 @@ function (Box2D, Parent, PhysicsEngine, ViewController, PlayerController, Notifi
GameController.prototype.update = function () {
requestAnimFrame(this.update.bind(this));
setTimeout(this.update.bind(this), Settings.BOX2D_TIME_STEP * 1000);
this.physicsEngine.update();
this.viewController.update();
if(this.me) {
this.me.update();
}
}
GameController.prototype.render = function() {
requestAnimFrame(this.render.bind(this));
this.viewController.render();
}
GameController.prototype.onWorldUpdate = function (updateData) {
var body = this.physicsEngine.world.GetBodyList();
@ -113,7 +118,7 @@ function (Box2D, Parent, PhysicsEngine, ViewController, PlayerController, Notifi
//this.onSpawnPlayer(options);
this.me = this.players[playerId];
this.me.setPlayerController(new PlayerController(this.me));
this.viewController.setMainPlayer(this.me);
this.viewController.setMe(this.me);
}
GameController.prototype.onSpawnPlayer = function(options) {
@ -125,7 +130,7 @@ function (Box2D, Parent, PhysicsEngine, ViewController, PlayerController, Notifi
player.spawn(x, y);
// add to view controller
this.viewController.addMovablePlayer(player);
this.viewController.addPlayer(player);
}
GameController.prototype.loadLevel = function (path) {