clean client code

This commit is contained in:
Asraelite 2016-03-24 13:26:35 +00:00
parent f3619ba891
commit 21a30ad212
18 changed files with 294 additions and 268 deletions

View file

@ -66,6 +66,7 @@ class Room {
sendWorld(player) {
let data = {
playerShipId: player.ship.id,
bounds: this.world.bounds,
bodies: Array.from(this.world.bodies).map(b => b.packFull())
};

View file

@ -33,10 +33,10 @@ class Body {
let pos = this.b2body.GetPosition();
let bounds = this.world.bounds;
if(pos.x < bounds.left) this.applyForce(0.003, 0);
if(pos.x > bounds.right) this.applyForce(-0.003, 0);
if(pos.y < bounds.top) this.applyForce(0, 0.003);
if(pos.y > bounds.bottom) this.applyForce(-0, -0.003);
if(pos.x < bounds.left) this.applyForce(0.03, 0);
if(pos.x > bounds.right) this.applyForce(-0.03, 0);
if(pos.y < bounds.top) this.applyForce(0, 0.03);
if(pos.y > bounds.bottom) this.applyForce(-0, -0.03);
}
packDelta() {

View file

@ -66,7 +66,6 @@ class Physics {
step() {
this.world.Step(1, 5, 1 / 60);
for (var i = 0; i < this.toRemove.length; i++) {
this.world.DestroyBody(this.toRemove[i].b2body);
}