mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
fixed server bugs
This commit is contained in:
parent
f85469b97e
commit
3afc2fa66e
5 changed files with 24 additions and 27 deletions
|
|
@ -16,6 +16,9 @@ function(Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, Not
|
|||
|
||||
this.update();
|
||||
this.updateWorld();
|
||||
|
||||
NotificationCenter.on('user/joined', this.userJoined, this);
|
||||
NotificationCenter.on('user/left', this.userLeft, this);
|
||||
}
|
||||
|
||||
GameController.prototype = Object.create(Parent.prototype);
|
||||
|
|
@ -26,13 +29,16 @@ function(Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, Not
|
|||
|
||||
this.physicsEngine.update();
|
||||
for(var id in this.players) {
|
||||
this.players[id].player.update();
|
||||
this.players[id].update();
|
||||
}
|
||||
}
|
||||
|
||||
GameController.prototype.userJoined = function(user) {
|
||||
var player = Parent.prototype.userJoined.call(this, user);
|
||||
this.inputControllers[player.id] = new InputController(player);
|
||||
Parent.prototype.userJoined.call(this, user);
|
||||
|
||||
var id = user.id;
|
||||
var player = this.players[id];
|
||||
this.inputControllers[id] = new InputController(player);
|
||||
}
|
||||
|
||||
GameController.prototype.userLeft = function(user) {
|
||||
|
|
@ -68,7 +74,7 @@ function(Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, Not
|
|||
} while (body = body.GetNext());
|
||||
|
||||
if(isUpdateNeeded) {
|
||||
NotificationCenter.trigger("sendCommandToAllUsers", ['gameCommand', {worldUpdate:update}]);
|
||||
//NotificationCenter.trigger("sendCommandToAllUsers", ['gameCommand', {worldUpdate:update}]);
|
||||
}
|
||||
|
||||
setTimeout(this.updateWorld.bind(this), Settings.WORLD_UPDATE_BROADCAST_INTERVAL);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue