Global Positioning System Reference
In-Depth Information
Note that the array length adds one entry for the local player, which should
match the remote player reflected by the server. Then, the player positions
can be set with
updatePlayerPositions();
Before the server starts to announce the player's moves one by one, the
destination arrays can be created and positioned outside of the map area
with
createDestinationArrays();
private int[] destRadius;
private Color[] destColors;
private Position[] destPositions;
The destinations that should be displayed with drawPositions raise a
conflict with the station arrays created earlier. Both arrays have constant
lengths, are merged with
mergePDArrays();
private int[] allRadius;
private Color[] allColors;
private Position[] allPositions;
and are managed with
checkedShowStations();
At the end of gameStart() , a Sampler thread is created to update all player
positions asynchronously to the actual game logic.
To assist the user in decision making, a single click on a station displays
all possible paths from the origin. By clicking on intermediate stations, the
paths can be reduced until a neighboring destination is displayed on the
map. A double click on the destination submits the move to the server and
starts the move.
Just like the destinations and stations have to be merged to be displayed,
the arrays
private Route[] routes;
private Color[] routeColors;
compete with the digital maps arrays and have to be managed by a GUI
logic.
Now, one or more users can play a game by simply clicking on the map.
Here is another mode that would be helpful:
Problem 13.7 (Implement an observer button.) Add a button to observe the
game instead of participating in the game.
 
Search WWH ::




Custom Search