server reconciliation OK (a little rubberbanding)
This commit is contained in:
@@ -50,8 +50,11 @@ class GameSession {
|
||||
clearInterval(s.gameLoopInterval);
|
||||
clearInterval(s.clientsUpdateInterval);
|
||||
}
|
||||
handleInput(client: ClientPlayer, input: en.InputEnum) {
|
||||
handleInput(client: ClientPlayer, inputEvent: ev.EventInput) {
|
||||
const gc = this.components;
|
||||
const input = inputEvent.input;
|
||||
client.lastInputId = inputEvent.inputId;
|
||||
|
||||
client.racket.dir.y = 0;
|
||||
if (input === en.InputEnum.up) {
|
||||
client.racket.dir.y += -1;
|
||||
@@ -96,9 +99,11 @@ class GameSession {
|
||||
type: en.EventTypes.gameUpdate,
|
||||
playerLeft: {y: gc.playerLeft.pos.y},
|
||||
playerRight: {y: gc.playerRight.pos.y},
|
||||
ball: {x: gc.ball.pos.x, y: gc.ball.pos.y, speed: gc.ball.speed}
|
||||
ball: {x: gc.ball.pos.x, y: gc.ball.pos.y, speed: gc.ball.speed},
|
||||
lastInputId: 0
|
||||
};
|
||||
s.playersMap.forEach( (client) => {
|
||||
update.lastInputId = client.lastInputId;
|
||||
client.socket.send(JSON.stringify(update));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user