rSimulate / Cosmosium

:earth_americas: js game engine for space-based games
Other
23 stars 7 forks source link

Asteroid colors #92

Closed BrianErikson closed 9 years ago

BrianErikson commented 9 years ago

Added five colors that are allowed to be assigned to the client by the server's game instance. If there are more than five players in the instance, it randomly generates new colors to be assigned to them. Those colors may or may not be attractive.

This merge allows us to dynamically draw glow shaders on asteroids for each player's claim, and allows the colors to be the same for each player, regardless of which client you are on. It automatically synchronizes on webGL context loss issues, as well as broadcasts new player's colors to all others on connection. If the instance is pickled, to be loaded again at a later date, the server will recognize that the player already has a color assigned, and will issue the same color to the player as before.

As of right now there is no way to change your color; it is assigned by player position in the login queue.

BrianErikson commented 9 years ago

The colors can be accessed in main.js, by an array called players. This houses the following object per player: {player: playerName, color: THREE.Color}