better network

This commit is contained in:
Marty Killian 2023-11-29 16:20:47 +01:00
parent 4aba4d8f4d
commit 49cc48b33a

View file

@ -3,7 +3,7 @@ class Network{
this.adress = adress;
this.connected = false;
this.playerId;
this.playerId = null;
this.playersToAdd = [];
this.playersToRemove = [];
this.playersToUpdate = [];
@ -24,7 +24,6 @@ class Network{
this.playersToAdd.push(new Player(data.data.id, data.data.x, data.data.y, data.data.name, data.data.dir));
break;
}
}
connect(){
@ -38,6 +37,13 @@ class Network{
})
}
getPlayerId(){
while(this.playerId==null){
//waiting for connection
};
return this.playerId;
}
update(obj){
this.socket.send(JSON.stringify({
type: "update",