Skip to content

Commit

Permalink
html
Browse files Browse the repository at this point in the history
ready up button
  • Loading branch information
Guerrero96 committed Apr 16, 2024
1 parent 936a2cc commit d7a054c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
<label for="username">Username:</label>
<input type="text" id="username" maxlength="20">
<button id="joinButton">Join Game</button>
<button id="readyButton" style="display: none;">Ready Up</button>
<div id="lobby-status">Waiting for players...</div>
<div id="players-in-lobby">Players in Lobby:</div>
<label id="topMessage"></label>
Expand Down Expand Up @@ -88,6 +89,7 @@
document.getElementById("lobby-status").innerHTML = "Waiting for other players...";
} else if (msg.action === "join") {
document.getElementById("lobby-status").innerHTML = "Joined the game!";
document.getElementById("readyButton").style.display = "inline"; // Show ready button after joining
}
};

Expand All @@ -109,6 +111,13 @@
alert("Please enter a username.");
}
});

// Add event listener for the Ready Up button
document.getElementById("readyButton").addEventListener("click", function() {
// Send a message to the server indicating that the player is ready
connection.send(JSON.stringify({ action: "ready" }));
document.getElementById("readyButton").disabled = true; // Disable the button after clicking
});
</script>
</body>
</html>

0 comments on commit d7a054c

Please sign in to comment.