improve syncing

This commit is contained in:
biglyderv 2024-09-29 17:07:22 -04:00
parent 30a1790534
commit 13e8784652
No known key found for this signature in database
GPG key ID: 33AC87E9ACE66954
2 changed files with 3 additions and 2 deletions

View file

@ -26,7 +26,7 @@ class Game extends GameBasic {
let that = this;
that.entities = [];
setInterval(function () { that.sync() }, 1000 / 20);
setInterval(function () { that.sync() }, 1000 / 5);
}
}

View file

@ -82,6 +82,7 @@ class Game extends GameBasic {
this.entities.push(this.player);
} else {
player.bump();
this.ws.send(JSON.stringify({ vel, dir, you }));
}
}
sync() {
@ -119,7 +120,7 @@ class Game extends GameBasic {
this.ws.addEventListener('message',function(e) { that.recv(e) });
setInterval(function () { that.render() }, 1000 / 60);
setInterval(function () { that.sync() }, 1000 / 20);
setInterval(function () { that.sync() }, 1000 / 5);
game.canvas.onclick = () => that.click();
}