Game Development Reference
In-Depth Information
Making a networked game - Battleships
In the previous recipes, we looked at how to set up a server, and connect and handle basic
messaging. In this recipe, we'll reinforce this knowledge and expand it by adding server
verification and applying it to a real game.
A turn-based board game is perhaps not what you would normally develop using a 3D
game SDK, but it's a very good game to learn networking. The Battleships game is a good
example not only because the rules are simple and known to many but also because it has a
hidden element, which will help us understand the concept of server verification.
Note
If you're unfamiliar with the Battleships game, visit http://www.wikipedia.org/wiki/Batt .
Since we're mainly interested in the networking aspects of the game, we'll skip some of the
verification normally needed such as looking for overlapping ships. We also won't write
any graphical interface and use the command prompt to obtain input. Again, to focus on the
networking API, some of the plain Java logic for game rules won't be explained.
The game will have a client and server class. Each class will have a MessageListener
implementation and share messages and game objects.
Search WWH ::




Custom Search