mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
refactoring
This commit is contained in:
parent
39af52dd14
commit
c256f8a729
8 changed files with 87 additions and 160 deletions
|
|
@ -50,37 +50,30 @@ function (Parent, PhysicsEngine, ViewController, KeyboardController, Notificatio
|
|||
|
||||
GameController.prototype.userJoined = function (user) {
|
||||
var player = Parent.prototype.userJoined.call(this, user);
|
||||
player.spawn(50, 50);
|
||||
//player.spawn(50, 50);
|
||||
return player;
|
||||
}
|
||||
/*
|
||||
GameController.prototype.userLeft = function (user) {
|
||||
Parent.prototype.userLeft.call(user);
|
||||
|
||||
GameController.prototype.onWorldUpdate = function (updateData) {
|
||||
|
||||
var body = this.physicsEngine.world.GetBodyList();
|
||||
do {
|
||||
var bodyName = body.GetUserData();
|
||||
if(bodyName && updateData[bodyName]) {
|
||||
var update = updateData[bodyName];
|
||||
body.SetAwake(true);
|
||||
body.SetPosition(update.p);
|
||||
body.SetAngle(update.a);
|
||||
body.SetLinearVelocity(update.lv);
|
||||
body.SetAngularVelocity(update.av);
|
||||
}
|
||||
} while (body = body.GetNext());
|
||||
|
||||
}
|
||||
*/
|
||||
GameController.prototype.processGameCommand = function (command, options) {
|
||||
|
||||
GameController.prototype.onPlayerSpawn = function(user) {
|
||||
|
||||
if (command == "worldUpdate") {
|
||||
|
||||
var body = this.physicsEngine.world.GetBodyList();
|
||||
do {
|
||||
var userData = body.GetUserData();
|
||||
if(userData && options[userData]) {
|
||||
var update = options[userData];
|
||||
|
||||
//console.log('position difference:', (body.GetPosition().y - update.p.y) * 30, body.GetLinearVelocity().y);
|
||||
|
||||
body.SetAwake(true);
|
||||
body.SetPosition(update.p);
|
||||
body.SetAngle(update.a);
|
||||
body.SetLinearVelocity(update.lv);
|
||||
body.SetAngularVelocity(update.av);
|
||||
}
|
||||
} while (body = body.GetNext());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
return GameController;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue