improve syncing
This commit is contained in:
parent
0ea8236567
commit
9353f7cbf0
2 changed files with 3 additions and 2 deletions
2
game.js
2
game.js
|
@ -26,7 +26,7 @@ class Game extends GameBasic {
|
||||||
let that = this;
|
let that = this;
|
||||||
that.entities = [];
|
that.entities = [];
|
||||||
|
|
||||||
setInterval(function () { that.sync() }, 1000 / 20);
|
setInterval(function () { that.sync() }, 1000 / 5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,7 @@ class Game extends GameBasic {
|
||||||
this.entities.push(this.player);
|
this.entities.push(this.player);
|
||||||
} else {
|
} else {
|
||||||
player.bump();
|
player.bump();
|
||||||
|
this.ws.send(JSON.stringify({ vel, dir, you }));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sync() {
|
sync() {
|
||||||
|
@ -119,7 +120,7 @@ class Game extends GameBasic {
|
||||||
this.ws.addEventListener('message',function(e) { that.recv(e) });
|
this.ws.addEventListener('message',function(e) { that.recv(e) });
|
||||||
|
|
||||||
setInterval(function () { that.render() }, 1000 / 60);
|
setInterval(function () { that.render() }, 1000 / 60);
|
||||||
setInterval(function () { that.sync() }, 1000 / 20);
|
setInterval(function () { that.sync() }, 1000 / 5);
|
||||||
|
|
||||||
game.canvas.onclick = () => that.click();
|
game.canvas.onclick = () => that.click();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue