messages draw on canvas

+ bugfix: vector.assign() Uncaught TypeError
This commit is contained in:
LuckyLaszlo
2022-11-28 04:40:03 +01:00
parent 7f248b5449
commit 5325c8b9ee
7 changed files with 48 additions and 27 deletions

View File

@@ -84,17 +84,11 @@ function gameUpdate(data: ev.EventGameUpdate)
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.pos.assign(data.ball.x, data.ball.y);
gc.ball.dir.assign(data.ball.dirX, data.ball.dirY);
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
}
@@ -113,11 +107,15 @@ function scoreUpdate(data: ev.EventScoreUpdate)
function matchEnd(data: ev.EventMatchEnd)
{
console.log("matchEnd");
if (data.winner === clientInfo.side) {
alert("WIN"); // placeholder TODO draw
gc.text1.pos.assign(c.w*0.415, c.h_mid);
gc.text1.text = "WIN";
}
else {
alert("LOSE"); // placeholder TODO draw
gc.text1.pos.assign(c.w*0.383, c.h_mid);
gc.text1.text = "LOSE";
}
// matchEnded = true;
}
// export let matchEnded = false;