fix ship respawning
This commit is contained in:
parent
8e0c4b02e4
commit
79dd88fd67
2 changed files with 12 additions and 3 deletions
|
@ -21,11 +21,12 @@ class Net {
|
||||||
});
|
});
|
||||||
|
|
||||||
this.socket.on('world', data => {
|
this.socket.on('world', data => {
|
||||||
game.world.clear();
|
window.q = data;
|
||||||
game.world.bounds = data.bounds;
|
game.world.bounds = data.bounds;
|
||||||
game.player.inputInterface = data.inputInterface;
|
game.player.inputInterface = data.inputInterface;
|
||||||
for (var b of data.bodies) {
|
if (data.bodies) {
|
||||||
game.world.add(b);
|
game.world.clear();
|
||||||
|
data.bodies.forEach(b => game.world.add(b));
|
||||||
}
|
}
|
||||||
game.world.setPlayerShip(data.playerShipId);
|
game.world.setPlayerShip(data.playerShipId);
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,6 +29,14 @@ class Spawner {
|
||||||
let ship = new Ship(this.world, pos, player);
|
let ship = new Ship(this.world, pos, player);
|
||||||
player.ship = ship;
|
player.ship = ship;
|
||||||
this.world.addShip(ship);
|
this.world.addShip(ship);
|
||||||
|
|
||||||
|
let data = {
|
||||||
|
playerShipId: player.ship.id,
|
||||||
|
inputInterface: player.inputInterface,
|
||||||
|
bounds: this.world.bounds,
|
||||||
|
};
|
||||||
|
|
||||||
|
player.sendWorld(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
spawnMissile(ship) {
|
spawnMissile(ship) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue