clean client code
This commit is contained in:
parent
f3619ba891
commit
21a30ad212
18 changed files with 294 additions and 268 deletions
|
@ -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())
|
||||
};
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue