Created
June 9, 2020 14:33
-
-
Save Srushtika/d583e5e68cbdd7a775d942bce0b65305 to your computer and use it in GitHub Desktop.
Code snippet 11 - For multiplayer space invaders article
This file contains hidden or 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
gameRoom.presence.subscribe("leave", (player) => { | |
let leavingPlayer = player.clientId; | |
alivePlayers--; | |
totalPlayers--; | |
delete players[leavingPlayer]; | |
if (totalPlayers <= 0) { | |
resetServerState(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment