diff --git a/game.js b/game.js index a3d422c..9e79a8d 100644 --- a/game.js +++ b/game.js @@ -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); } } diff --git a/static/js/index.js b/static/js/index.js index 13d483e..f9d5aa2 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -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(); }