reduce update packets sent

This commit is contained in:
Asraelite 2016-03-30 12:50:59 +01:00
parent d6daed2e9b
commit ef2d067b38
15 changed files with 67 additions and 14 deletions

View file

@ -162,16 +162,16 @@ class World {
tick() {
this.physics.step();
let tickBodies = (set, interval) => {
let tickBodies = (set, interval, canSleep) => {
set.forEach(body => {
if (this.tickCount % interval == 0)
if (this.tickCount % interval == 0 && body.awake)
body.applyDelta();
body.tick();
});
};
tickBodies(this.ships, 1);
tickBodies(this.asteroids, 4);
tickBodies(this.asteroids, 1);
tickBodies(this.projectiles, 1);
if (Date.now() - this.tpsStart > 5000) {