better network
This commit is contained in:
parent
4aba4d8f4d
commit
49cc48b33a
1 changed files with 8 additions and 2 deletions
|
@ -3,7 +3,7 @@ class Network{
|
||||||
this.adress = adress;
|
this.adress = adress;
|
||||||
this.connected = false;
|
this.connected = false;
|
||||||
|
|
||||||
this.playerId;
|
this.playerId = null;
|
||||||
this.playersToAdd = [];
|
this.playersToAdd = [];
|
||||||
this.playersToRemove = [];
|
this.playersToRemove = [];
|
||||||
this.playersToUpdate = [];
|
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));
|
this.playersToAdd.push(new Player(data.data.id, data.data.x, data.data.y, data.data.name, data.data.dir));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
connect(){
|
connect(){
|
||||||
|
@ -38,6 +37,13 @@ class Network{
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPlayerId(){
|
||||||
|
while(this.playerId==null){
|
||||||
|
//waiting for connection
|
||||||
|
};
|
||||||
|
return this.playerId;
|
||||||
|
}
|
||||||
|
|
||||||
update(obj){
|
update(obj){
|
||||||
this.socket.send(JSON.stringify({
|
this.socket.send(JSON.stringify({
|
||||||
type: "update",
|
type: "update",
|
||||||
|
|
Loading…
Reference in a new issue