Added game state, allow paddle movement

This commit is contained in:
2022-11-04 00:13:00 +01:00
parent 462e27c88a
commit a4e22a4c52
7 changed files with 96 additions and 13 deletions

View File

@@ -79,6 +79,16 @@ leavelobby.addEventListener("click", function (event) {
event.preventDefault();
});
function movePaddle(direction) {
connection.invoke("MovePaddle", direction).catch(function (err) {
return console.error(err.toString());
});
}
function moveUp() { return movePaddle(-1); }
function stopPaddle() { return movePaddle(0); }
function moveDown() { return movePaddle(1); }
connection.start().then(function () {
console.info(`Connected!`);
connectionStatus.textContent = "Connected!";