bump sync fix for real
This commit is contained in:
parent
6c05369ef8
commit
e84027150e
3 changed files with 14 additions and 12 deletions
|
@ -34,10 +34,12 @@ function Player(you, isPlayer) {
|
|||
Player.prototype.bump = function () {
|
||||
let player = this;
|
||||
|
||||
if (player.ticks < 10) {
|
||||
if (player.ticks < 7) {
|
||||
player.dir *= -1;
|
||||
}
|
||||
|
||||
console.log(player.ticks)
|
||||
|
||||
player.vel.x *= 0.3;
|
||||
player.vel.y *= 0.3;
|
||||
|
||||
|
|
4
index.js
4
index.js
|
@ -30,8 +30,8 @@ app.ws('/', function (ws, req) {
|
|||
console.log(err);
|
||||
data = {};
|
||||
}
|
||||
let { vel, dir, you } = data;
|
||||
let data2 = { vel, dir, you };
|
||||
let { vel, dir, you, ticks } = data;
|
||||
let data2 = { vel, dir, you, ticks };
|
||||
game.entities[playerI] = Object.assign(game.entities[playerI], data2);
|
||||
})
|
||||
|
||||
|
|
|
@ -91,9 +91,9 @@ class Game extends GameBasic {
|
|||
sync() {
|
||||
let { player } = this;
|
||||
|
||||
let { vel, dir, you } = player;
|
||||
let { vel, dir, you, ticks } = player;
|
||||
|
||||
this.ws.send(JSON.stringify({ vel, dir, you }));
|
||||
this.ws.send(JSON.stringify({ vel, dir, you, ticks }));
|
||||
}
|
||||
recv({ data }) {
|
||||
let { player } = this;
|
||||
|
|
Loading…
Reference in a new issue