improve multiplayer

This commit is contained in:
Asraelite 2016-03-22 19:20:50 +00:00
parent 0aa259b874
commit 2fffe574c1
10 changed files with 76 additions and 19 deletions

View file

@ -25,12 +25,16 @@ class Player {
});
}
send(msg, data) {
this.connection.send(msg, data);
}
sendWorld(data) {
this.connection.send('world', data);
}
sendUpdate() {
if (Object.keys(this.delta).length == 0) return;
if (Object.keys(this.delta).length == 0 || Math.random() < 0) return;
this.connection.send('update', this.delta);
this.delta = {};
}