Adding + removing players

This commit is contained in:
Atsuyo-INSA 2023-11-29 19:22:32 +01:00
parent 7f84496398
commit 4731216d3a

View file

@ -53,6 +53,23 @@ function game() {
}
}
}
let playersToAdd = Net.getPlayersToAdd();
if (playersToAdd.length!=0)
console.log("added ",playersToAdd.length);
players.concat(playersToAdd);
let playerToRemove = Net.getPlayersToRemove();
for(let id in playerToRemove)
{
console.log("deleting ",id);
for(let i = 0;i<players.length;i++)
{
if (players[i].id==id)
{
players.splice(i,1);
break;
}
}
}
player.update([],[], dt);
for (var i = players.length - 1; i >= 0; i--) {
players[i].update([],[], dt);//squares, circles