Skip to content

Instantly share code, notes, and snippets.

@MikeShi42
Created August 13, 2018 17:51
Show Gist options
  • Save MikeShi42/bc90834ab1ec1912429e433d33757c78 to your computer and use it in GitHub Desktop.
Save MikeShi42/bc90834ab1ec1912429e433d33757c78 to your computer and use it in GitHub Desktop.
function startGame() {
let seconds = 4; // Number of seconds + 1 to wait
// Start a countdown timer
const intervalId = setInterval(function() {
// Subtract the number of seconds left and update UI
seconds--;
countdownMessage(true, seconds);
if (seconds == 0) { // It's time to start the game!
clearInterval(intervalId); // Stop the countdown
countdownMessage(false, 0); // Hide the countdown message
if (remoteGame != null && localGame != null) {
localGame.restart(); // A game already exists, lets just reset the game.
} else {
// Start the game managers
remoteGame.setup();
localGame.setup();
}
}
}, 1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment