server handleInput rework done
This commit is contained in:
@@ -52,19 +52,18 @@ class GameSession {
|
||||
}
|
||||
private _handleInput(delta: number, client: ClientPlayer) {
|
||||
const gc = this.components;
|
||||
client.inputArr.forEach( (value) => {
|
||||
const input = value.input;
|
||||
client.racket.dir.y = 0;
|
||||
if (input === en.InputEnum.up) {
|
||||
client.racket.dir.y = -1;
|
||||
}
|
||||
else if (input === en.InputEnum.down) {
|
||||
client.racket.dir.y = 1;
|
||||
}
|
||||
client.racket.moveAndCollide(delta, [gc.wallTop, gc.wallBottom]);
|
||||
});
|
||||
client.lastInputId = client.inputArr[client.inputArr.length - 1].inputId;
|
||||
client.inputArr.length = 0;
|
||||
const input = client.inputBuffer.input;
|
||||
|
||||
if (input === en.InputEnum.up) {
|
||||
client.racket.dir.y = -1;
|
||||
}
|
||||
else if (input === en.InputEnum.down) {
|
||||
client.racket.dir.y = 1;
|
||||
}
|
||||
client.racket.moveAndCollide(delta, [gc.wallTop, gc.wallBottom]);
|
||||
|
||||
client.lastInputId = client.inputBuffer.inputId;
|
||||
client.inputBuffer = null;
|
||||
}
|
||||
private _gameLoop(s: GameSession) {
|
||||
/* s.last_time = s.actual_time;
|
||||
@@ -72,10 +71,8 @@ class GameSession {
|
||||
s.delta_time = (s.actual_time - s.last_time) / 1000; */
|
||||
s.delta_time = c.fixedDeltaTime;
|
||||
|
||||
console.log(s.delta_time);
|
||||
|
||||
s.playersMap.forEach( (client) => {
|
||||
if (client.inputArr.length != 0) {
|
||||
if (client.inputBuffer) {
|
||||
s._handleInput(s.delta_time, client);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user