improve multiplayer
This commit is contained in:
parent
0aa259b874
commit
2fffe574c1
10 changed files with 76 additions and 19 deletions
|
@ -7,7 +7,7 @@ class Room {
|
|||
this.players = new Set();
|
||||
this.teamA = new Set();
|
||||
this.teamB = new Set();
|
||||
this.world = new World();
|
||||
this.world = new World(this);
|
||||
this.name = (Math.random() * 100000 | 0).toString(36);
|
||||
|
||||
this.start();
|
||||
|
@ -42,6 +42,10 @@ class Room {
|
|||
self.players.forEach(player => player.sendUpdate());
|
||||
}
|
||||
|
||||
broadcast(msg, data) {
|
||||
this.players.forEach(player => player.send(msg, data));
|
||||
}
|
||||
|
||||
sendWorld(player) {
|
||||
let data = {
|
||||
playerShipId: player.ship.id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue