Created
August 13, 2018 17:51
-
-
Save MikeShi42/bc90834ab1ec1912429e433d33757c78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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