input desynchro, rollback to instant handle.
This commit is contained in:
@@ -39,7 +39,7 @@ class GameSession {
|
||||
});
|
||||
|
||||
s.actual_time = Date.now();
|
||||
s.gameLoopInterval = setInterval(s._gameLoop, c.gameLoopIntervalMS, s);
|
||||
s.gameLoopInterval = setInterval(s._gameLoop, c.serverGameLoopIntervalMS, s);
|
||||
s.clientsUpdateInterval = setInterval(s._clientsUpdate, c.clientsUpdateIntervalMS, s);
|
||||
}
|
||||
pause(s: GameSession) {
|
||||
@@ -50,7 +50,11 @@ class GameSession {
|
||||
clearInterval(s.gameLoopInterval);
|
||||
clearInterval(s.clientsUpdateInterval);
|
||||
}
|
||||
instantInputDebug(client: ClientPlayer) {
|
||||
this._handleInput(c.fixedDeltaTime, client);
|
||||
}
|
||||
private _handleInput(delta: number, client: ClientPlayer) {
|
||||
// if (client.inputBuffer === null) {return;}
|
||||
const gc = this.components;
|
||||
const input = client.inputBuffer.input;
|
||||
|
||||
@@ -60,10 +64,13 @@ class GameSession {
|
||||
else if (input === en.InputEnum.down) {
|
||||
client.racket.dir.y = 1;
|
||||
}
|
||||
client.racket.moveAndCollide(delta, [gc.wallTop, gc.wallBottom]);
|
||||
|
||||
if (input !== en.InputEnum.noInput) {
|
||||
client.racket.moveAndCollide(delta, [gc.wallTop, gc.wallBottom]);
|
||||
}
|
||||
|
||||
client.lastInputId = client.inputBuffer.inputId;
|
||||
client.inputBuffer = null;
|
||||
client.lastInputId = client.inputBuffer.id;
|
||||
// client.inputBuffer = null;
|
||||
}
|
||||
private _gameLoop(s: GameSession) {
|
||||
/* s.last_time = s.actual_time;
|
||||
@@ -71,11 +78,10 @@ class GameSession {
|
||||
s.delta_time = (s.actual_time - s.last_time) / 1000; */
|
||||
s.delta_time = c.fixedDeltaTime;
|
||||
|
||||
s.playersMap.forEach( (client) => {
|
||||
if (client.inputBuffer) {
|
||||
s._handleInput(s.delta_time, client);
|
||||
}
|
||||
});
|
||||
// WIP, replaced by instantInputDebug() to prevent desynchro
|
||||
/* s.playersMap.forEach( (client) => {
|
||||
s._handleInput(s.delta_time, client);
|
||||
}); */
|
||||
|
||||
const gc = s.components;
|
||||
if (gc.ballInPlay)
|
||||
|
||||
Reference in New Issue
Block a user