Created
August 13, 2018 18:10
-
-
Save MikeShi42/d734a6d9a2701d0d085edb7d12710138 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
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