mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
trying to smothen the differences between server and client
This commit is contained in:
parent
47bb5ef147
commit
cda69dcfd4
1 changed files with 20 additions and 2 deletions
|
|
@ -63,8 +63,8 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
||||||
var gameObject = userData;
|
var gameObject = userData;
|
||||||
if(updateData[gameObject.uid]) {
|
if(updateData[gameObject.uid]) {
|
||||||
var update = updateData[gameObject.uid];
|
var update = updateData[gameObject.uid];
|
||||||
body.SetAwake(true);
|
body.SetAwake(true);
|
||||||
body.SetPosition(update.p);
|
body.SetPosition(this.centerBetween(update.p, body.GetPosition()));
|
||||||
body.SetAngle(update.a);
|
body.SetAngle(update.a);
|
||||||
body.SetLinearVelocity(update.lv);
|
body.SetLinearVelocity(update.lv);
|
||||||
body.SetAngularVelocity(update.av);
|
body.SetAngularVelocity(update.av);
|
||||||
|
|
@ -80,6 +80,24 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GameController.prototype.centerBetween = function(n, o) {
|
||||||
|
var x, y;
|
||||||
|
|
||||||
|
if(n.x > o.x) {
|
||||||
|
x = o.x + (n.x - o.x) / 2;
|
||||||
|
} else {
|
||||||
|
x = o.x - (o.x - n.x) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(n.y > o.y) {
|
||||||
|
y = o.y + (n.y - o.y) / 2;
|
||||||
|
} else {
|
||||||
|
y = o.y - (o.y - n.y) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {x:x, y:y};
|
||||||
|
};
|
||||||
|
|
||||||
GameController.prototype.onJoinMe = function (playerId) {
|
GameController.prototype.onJoinMe = function (playerId) {
|
||||||
this.me = this.players[playerId];
|
this.me = this.players[playerId];
|
||||||
this.me.setPlayerController(new PlayerController(this.me));
|
this.me.setPlayerController(new PlayerController(this.me));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue