mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added getSpawnedPlayersAndTheirPositions in order to get already spawned players to spawn the moment you join and spawn yourself. fixes #26
This commit is contained in:
parent
a852bccae6
commit
a1e94e1ed0
6 changed files with 55 additions and 8 deletions
|
|
@ -91,5 +91,34 @@ function (Parent, PhysicsEngine, Settings, InputController, requestAnimFrame, No
|
|||
setTimeout(this.updateWorld.bind(this), Settings.WORLD_UPDATE_BROADCAST_INTERVAL);
|
||||
}
|
||||
|
||||
GameController.prototype.getSpawnedPlayers = function() {
|
||||
var spawnedPlayers = {};
|
||||
for(player in this.players) {
|
||||
if(player.isSpawned) {
|
||||
spawnedPlayers[player.id] = player;
|
||||
}
|
||||
}
|
||||
return spawnedPlayers;
|
||||
};
|
||||
|
||||
GameController.prototype.getSpawnedPlayersAndTheirPositions = function() {
|
||||
var spawnedPlayers = [];
|
||||
for(id in this.players) {
|
||||
var player = this.players[id];
|
||||
if(player.isSpawned) {
|
||||
spawnedPlayers.push({
|
||||
id: id,
|
||||
x: player.getPosition().x * Settings.RATIO,
|
||||
y: player.getPosition().y * Settings.RATIO
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: OR: use get Spawned Players and fetch them into a sort of transfer objects
|
||||
// that contains only necessary data
|
||||
|
||||
return spawnedPlayers;
|
||||
};
|
||||
|
||||
return GameController;
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue