+ client prediction
This commit is contained in:
LuckyLaszlo
2022-11-22 00:06:07 +01:00
parent 04203f4f9d
commit 2b9058ad49
43 changed files with 53 additions and 15 deletions

View File

@@ -27,24 +27,23 @@ function handleInput(delta: number)
function playerMove(delta: number, keys: string[])
{
if (keys.indexOf("w") != -1) {
if (keys.indexOf("w") != -1 || keys.indexOf("ArrowUp".toLowerCase()) != -1) {
socket.send(JSON.stringify(new EventInput(InputEnum.up)));
}
if (keys.indexOf("s") != -1) {
if (keys.indexOf("s") != -1 || keys.indexOf("ArrowDown".toLowerCase()) != -1) {
socket.send(JSON.stringify(new EventInput(InputEnum.down)));
}
// prediction
/* const racket = clientInfo.racket;
const racket = clientInfo.racket;
racket.dir.y = 0;
if (keys.indexOf("w") != -1) {
if (keys.indexOf("w") != -1 || keys.indexOf("ArrowUp".toLowerCase()) != -1) {
racket.dir.y += -1;
}
if (keys.indexOf("s") != -1) {
if (keys.indexOf("s") != -1 || keys.indexOf("ArrowDown".toLowerCase()) != -1) {
racket.dir.y += 1;
}
racket.moveAndCollide(delta, [gc.wallTop, gc.wallBottom]); */
racket.moveAndCollide(delta, [gc.wallTop, gc.wallBottom]);
}
export {handleInput}