Global Positioning System Reference
In-Depth Information
and used in the abstract LCPlayer |but is not being set there. To make
the user's life as easy as possible, the GUIPlayer implements a map click to
find the closest station:
stationID = board.findClosestStation( click );
stationPos = board.getNodeMap(). get( stationID );
stationName = board.getStationMap().get( stationID );
and a double click sets the player's origin and the underlying real object's
position:
myOrigin = stationID;
setPosition( stationPos );
At this point, the player can enter with the \enter game" button to
invoke
enterScenario();
...
roApp.enter( this.getRemotePlayer() );
and the server immediately echoes
serverStatusUpdate > "NEWPLAYER ROserver/Player10"
After entering, the player has to wait for other players to enter until one
game is loaded. For a straightforward development, this status is volatile
and the user should simply wait for the notification via
serverStatusUpdate > "STARTGAME" > gameStart()
This can then be achieved by launching another JVM with the RandomPlayer
.main method or with additional GUIPlayer s. Although each new player
is announced, the quick implementation waits for the game start, before
creating fixed-length player arrays with createPlayerArrays()
private int[] plyRadius;
private Color[] plyColors;
private Position[] plyPositions;
with the predefined colors
private Color myColor = Color.BLUE, runColor = Color.RED;
private Color[] playerColors = {
Color.DARK_GRAY, Color.BLACK, Color.CYAN,
Color.MAGENTA, Color.PINK, Color.ORANGE, Color.GREEN };
Since arrays have a given order of ordinal numbers, an index is added
to look up the array index by player ID:
/** Map player ID to index of fillPositions. */
private Map<Object, Integer> player2index;
 
Search WWH ::




Custom Search