Network-based Game

by

Chan Ho Kay

Chan Ho Leung, Billy

Chan Kwong Chui, Frankie

Advised by

Prof. Frederick H. Lochovsky

 



 

A real time strategy game
By

Introduction

With the excellent performance of present computer hardware, people can develop illustrious computer games. The distinctive video, audio and sense organ stimulation must attract more people to play computer games. Microsoft®, the most famous and successful computer company, also recognizes the strength of computer games. They exploit a television game machine utilizing computer games, so that people without computers can also partake of the excellent games in this age. In Hong Kong, there are several famous computer game producers. They have invited some idols to join the game as a character in order to attract people.

That is why we choose network-based, computer game as our project topic. It is hot and attractive. We are also computer game fans and play thousands of computer and television games. We would like to use our computer knowledge gained from the academic aspects to develop an attractive multiplayer, network-based computer game.

We aim at providing a real-time strategy game with three-dimensional (3D) graphics and user-friendly interface to the computer users. Real-time strategy game is a game in which all actions are performed in real time.

Methodology

Our game implementation is based on DirectX® SDK, which is a development tool providing Application Programming Interfaces (APIs) such as graphics API, network API, input device API and sound API. These APIs reduce the game development time. Different methods are applied to different parts of our program. DirectInput is used to implement the mouse movement and action. We make use of DirectSound to play the WAV files and add some sound effects to the game. The network API is called DirectPlay and it is used in the multiplayer mode. The host of the game is the server. We initialize the DirectPlay connection and create a session for each player that joins the game. The most important part of the API is Direct3D in the graphics API.

Figure 1: Architecture of Direct3D. It handles the low level operations for us, so we have a hardware independent environment to develop our game.

 



 

DirectPlay (Connection Establishing)

DirectX®'s DirectPlay API is used to develop the network prototype. Instructions are distributed to every computer through the network. Based on the simple communication between server and clients, control between computers is implemented. An alternative is Socket programming, but because of consistency of using DirectX® APIs, DirectPlay is chosen.

Before computers can communicate with each other, we need to initialize the network. The initialization functions are separated into server part and client part. The first step in using DirectPlay is to select which service provider to use. The service provider determines what type of network or protocol will be used for communications. DirectPlay contains four service providers, TCP/IP, IPX, Modem-to-Modem and Serial Link. We use TCP/IP in our game. The host will check the network status using the service provider. If it is ready, a session can be created. A session is a communications channel between several computers. Before an application can start communicating with other computers, it must be part of a session. After the session is created, other players can join the game by selecting the existing session. We can identify different sessions by a session name, which is entered by the host's player. Every player has a unique player ID. The program can identify the players by their ID so that messages can be sent to a specific player.

DirectPlay (Data Communication)

After a connection is established among computers, messages can be exchanged. A data structure is created

for messages sent or received; then information can be exchanged by a known format. The format of a message is fixed, for example, when one player side moves the army, a movement message is sent in a certain format. On the other hand, when a message is received, the computer takes the action corresponding to the action command in the message.

Direct3D (Graphics and Elements Design)

We render a 3D model by using the Direct3D immediate mode API. The 3D models are created by 3D Studio Max and converted into .x format. We can load a .x file in our program with some textures. The Picking-Object main function is used to select objects by clicking the mouse. The object is in a 3D environment, but the mouse has only two-dimensional movement. When the mouse is clicked on the screen, a ray is projected in the same direction as the player's view. The picked object is the first object pointed at by the ray.

Figure 2: Mapping between screen and the 3D space.

 



 

Results


Figure 3: Multiplayer network setup dialog.


Figure 4: Single-player mode startup screen.


Figure 5: In-game snapshot.

There are two armies, green and red color. They are attacking each other. The left bottom green square is the radar showing the location of the player's tanks.

Conclusion

DirectX® is powerful for creating a game. With the help of DirectX®, we have developed a fast, minimum latency, creative, attractive, multiplayer and real-time strategy tanks war game.

We have created a web page for this project,

"http://threechan.uhome.net"

We have published the executable code for our game in that home page.

There are some possible future extensions. For the graphics part, more different objects should be added. The attacking objects only contain tanks; air force, such as F14 fighters, should be added in order to widen the attacking possibilities. The game should be able to be played all over the world. Currently, the game just supports a Local Area Network. This limits players who can play to be only within the same place. After adding this improvement, players can play the game in their home.