Skip to content

Instantly share code, notes, and snippets.

@Srushtika
Created June 9, 2020 14:33
Show Gist options
  • Save Srushtika/d583e5e68cbdd7a775d942bce0b65305 to your computer and use it in GitHub Desktop.
Save Srushtika/d583e5e68cbdd7a775d942bce0b65305 to your computer and use it in GitHub Desktop.
Code snippet 11 - For multiplayer space invaders article
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