This commit is contained in:
biglyderv 2024-11-25 14:14:21 -05:00
parent edd005cb4d
commit 5414c719f1
6 changed files with 141 additions and 10 deletions

View file

@ -155,7 +155,11 @@ class Game extends GameBasic {
player.ref = false;
}
this.ws.send(JSON.stringify(player.legalProps.map(prop => player[prop])));
let p = player.legalProps.map(prop => player[prop]);
p.splice(0,0,'SYNC');
this.ws.send(JSON.stringify(p));
}
recv({ data }) {
let { player } = this;
@ -225,6 +229,7 @@ class Game extends GameBasic {
if (this.entities.length == 0) this.entities = [this.player];
}
async init() {
let tok = new URL(window.location).searchParams.get('token');
super.init();
let that = this;
@ -235,6 +240,9 @@ class Game extends GameBasic {
this.ws.addEventListener('open', function () {
that.sync(true);
if (tok) {
that.ws.send(JSON.stringify(["AUTH",tok]));
}
setInterval(function () { that.sync() }, 1000 / 5);
})