Some years ago, with my friends I have played Bomberman for Nintendo. Since the game is very entertaining to play and fairly easy to implement, I develop a similar multi-player game in Java.
The characteristics of my version of Bomberman are:
The program operated by the clients is SpaceBomber. The server that coordinates the clients is BombMaster.
If you would like to play the game, please make sure Java version 1.5 or higher is installed on your computer. Then, download the archive below, and unzip it to a location of your choice. To run SpaceBomber, execute the file run_client.bat.
|BombMaster SpaceBomber with Source (Java 1.5)||SpaceBomber.zip||800 kB|
One of the secrets of life is that
all that is really worth the doing
is what we do for others.
Charles Lutwidge Dodgson
Use the arrow keys to orient, and move your SpaceBomber within the map. Bombs are either dropped or thrown in the direction of your view.
The number keys 1, 2, 3, and 4 select the type of bomb. Bombs of type 1, and 2 are infinitely available. The third, and fourth type create a huge detonation and need to be collected over the course of the game.
Blank space drops, or throws an explosive depending on the type.
The return key kicks a small bomb, that has been dropped previously.
Page up, and down change the appearance of your SpaceBomber character. This way team play can be agreed on.
You're not drunk
if you can lie on the floor
without holding on.
I encourage you to design levels, so they can be added to the servers repository and played online.
It's really simple - click on the examples to the right.
The commands in the header have the following meaning:
players 2 to 4 map is played by at least 2 and by at most 4 SpaceBombers minutes 4 time until game continues on another worldmap pickups 7 maximum number of pickup items that are available on the map pickavg 40 average number of frames until a new pickup item appears warprej 3 average number of attempts until warp rejects warping a bomb noshild optional command to exclude protective shields from pickup items credits nick nick of map designer
The array of characters correspond to the architecture in the map:
You have to do your own growing no matter
how tall your grandfather was.
Communication: For initialization, the client preforms the following steps
During regular game play, the client just forwards the key-presses to the server via UDP. When the server fails to receive these packets, the server will unregister the client after a certain while.
The server simulates the game by processing the key-presses of the clients, and animating the entities. The server provides all clients with the current state of the game via UDP, ideally at a rate of 13 times per second. The information is just sufficient for drawing: index of current map, location of players, explosions, bombs, pickup items. The information is identical for all clients except for a single byte that indicates the bomb type selected by the individual client. Besides that, the server is also listening for new clients that would like to join the game.
In my experience, the TCP communication is successful from all over the world. On the other hand, the transfer of UDP packets might be denied from clients at distant locations, or with slow Internet connection. When operating the server in Kiruna/Sweden, clients from Germany, and Malaysia could play the game, whereas people from Canada and Argentina would not get beyond the initialisation via TCP.
Implementation: The classes for the server and the client are static. Each has a function main() - because we require two different programs. However, I intertwine the code of the two programs to avoid redundancy. For instance, there is a single variable for the server UDP port. The server program assigns the variable when initializing the port. However, the client will obtain the information only via (TCP) communication and assign the variable accordingly.
Graphics: All "animations" are flip-books. The different frames are stored in gif-files, that have transparent background.
Wie der kleine Moritz sich
die Weltgeschichte vorstellt,
so ist sie auch.