Skip to content

Instantly share code, notes, and snippets.

@MikeShi42
Created August 13, 2018 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MikeShi42/d734a6d9a2701d0d085edb7d12710138 to your computer and use it in GitHub Desktop.
Save MikeShi42/d734a6d9a2701d0d085edb7d12710138 to your computer and use it in GitHub Desktop.
window.requestAnimationFrame(function () {
...
localGame = new GameManager(socket, false, 4, KeyboardInputManager, HTMLActuator, LocalStorageManager);
// Add this socket lisetner
socket.on('player-number', function (playerNumber) {
if (playerNumber == 1) {
waitingPlayerTwo(true); // Show waiting message
// On 2nd player connect, start the game
socket.on('player-connect', function() {
waitingPlayerTwo(false); // Hide waiting message
startGame();
});
} else { // Immediately start the game if we're player two
startGame();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment