collision algo with Hugo

+ ball.dir added to EventGameUpdate
This commit is contained in:
LuckyLaszlo
2022-11-25 14:54:17 +01:00
parent 3474d54a2b
commit 4aafbac1a5
6 changed files with 93 additions and 37 deletions

View File

@@ -81,12 +81,20 @@ function inGameListener(event: MessageEvent)
function gameUpdate(data: ev.EventGameUpdate)
{
console.log("gameUpdate");
gc.playerLeft.pos.y = Math.floor(data.playerLeft.y);
gc.playerRight.pos.y = Math.floor(data.playerRight.y);
gc.ball.pos.x = Math.floor(data.ball.x);
gc.ball.pos.y = Math.floor(data.ball.y);
gc.ball.speed = Math.floor(data.ball.speed);
gc.playerLeft.pos.y = data.playerLeft.y;
gc.playerRight.pos.y = data.playerRight.y;
gc.ball.pos.x = data.ball.x;
gc.ball.pos.y = data.ball.y;
gc.ball.speed = data.ball.speed;
gc.ball.dir.x = data.ball.dirX;
gc.ball.dir.y = data.ball.dirY;
// ERROR: Uncaught TypeError: gc.ball.pos.assign is not a function
// Why ?
// gc.ball.pos.assign( data.ball.x, data.ball.y );
repeatInput(data.lastInputId); // server reconciliation
}