diff --git a/app/Game/Client/GameController.js b/app/Game/Client/GameController.js index 6ca7a1c..2f08ab6 100755 --- a/app/Game/Client/GameController.js +++ b/app/Game/Client/GameController.js @@ -63,8 +63,8 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Notificat var gameObject = userData; if(updateData[gameObject.uid]) { var update = updateData[gameObject.uid]; - body.SetAwake(true); - body.SetPosition(update.p); + body.SetAwake(true); + body.SetPosition(this.centerBetween(update.p, body.GetPosition())); body.SetAngle(update.a); body.SetLinearVelocity(update.lv); 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) { this.me = this.players[playerId]; this.me.setPlayerController(new PlayerController(this.me));