update position on death
This commit is contained in:
parent
02f3c87804
commit
5cd1b4fd59
1 changed files with 17 additions and 8 deletions
25
js/game.js
25
js/game.js
|
@ -32,15 +32,24 @@ function update()
|
|||
let playerToUpdate = Net.getPlayersToUpdate();
|
||||
for (let i = 0;i<playerToUpdate.length;i++)
|
||||
{
|
||||
for (let j = 0;j<players.length;j++)
|
||||
{
|
||||
if(players[j].id==playerToUpdate[i].id)
|
||||
if(playerToUpdate[i].id==player.id) {
|
||||
player.x=playerToUpdate[i].x;
|
||||
player.y=playerToUpdate[i].y;
|
||||
player.dir=playerToUpdate[i].dir;
|
||||
player.visibleDir=playerToUpdate[i].visibleDir;
|
||||
break;
|
||||
} else {
|
||||
for (let j = 0;j<players.length;j++)
|
||||
{
|
||||
players[j].x=playerToUpdate[i].x;
|
||||
players[j].y=playerToUpdate[i].y;
|
||||
players[j].dir=playerToUpdate[i].dir;
|
||||
players[j].visibleDir=playerToUpdate[i].visibleDir;
|
||||
break;
|
||||
if(players[j].id==playerToUpdate[i].id)
|
||||
{
|
||||
|
||||
players[j].x=playerToUpdate[i].x;
|
||||
players[j].y=playerToUpdate[i].y;
|
||||
players[j].dir=playerToUpdate[i].dir;
|
||||
players[j].visibleDir=playerToUpdate[i].visibleDir;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue