The DirectPlay net support enables to transfer information via net connection by programs in real time. DirectPlay may be utilized when running games with several computers connected in a local or a public net, as for example Internet. Beside for games, DirectPlay has a great significance in many other spheres requiring program communications in various computers carried out in real time. A typical example are examining and tutorial programs in classrooms. A precondition for running the DirectPlay net support is the installation of DirectX drivers of 5.0 or higher version. In the Windows 98 system these drivers are already included in the system's basic equipment.
The use of the DirectPlay net support consists in the following steps:
1. Connection selection. The connection determines the connection type of computers as to the hardware (serial cable, modem, local IPX net, public TCP net). In addition, in some connection types the address of the computer is decisive that has created the game and that will be controlling computer of the game.
2. Game selection. Several independent games can be run on the selected connection. It is possible to be connected to an already running game or to create a new game. The controlling computer (which has created the game) can set specified game parameters.
3. Player creation. To be connected to a game, it is necessary to create a player. After the player has been created, it is possible to communicate with the other players taking part in the game, and to transfer the game data.
4. Game data transfer. During playing the game each player will send game information, concerning, for example, the player motion etc., to the other game participants (players).
list of connections
The list of connections element returns a multiline text list of names of possible computer connections. An empty list indicates that no DirectX service of 5.0 version as a minimum is installed.
The active connection element makes it possible to set or to find out an active connection selected. When setting the connection one of the connection list lines is entered as a parameter. If the corresponding connection is not found in the list, then abbreviated comparison is performed by searching key strings in the connection names: "IPX", "TCP", "MODEM" and "SERIAL". The key strings can thus be used, when selecting the connection by a program, as abbreviations. If an empty text is entered, the active connection is discontinued and, at same time, the running game is interrupted. Returning an empty text means that the connection selected is not supported by the computer (no modem is installed, for example).
IP address of this computer
The IP address of this computer element returns the IP address of the computer in the text form, for example: "126.96.36.199". The IP address is an address that the computer will receive as assigned by the controlling server after being connected to the Internet. A typical procedure when playing a game through the Internet net is as follows: One of the players creates the game (the connection selected is TCP/IP), locates the IP address in the game window (this can be different in several Internet connection), communicates this address by phone or better by E-mail to the other players. The players select game connections and enter the address communicated as the controlling computer address.
list of games
The list of games element returns a multiline list of games that are running on the selected connection. In addressed connections, such as the Internet TCP, before looking up the game list the address of the computer is requested by the system on which the running games are supposed to be looked up. In the local nets the running games can be looked up on all computers by leaving out the computer address entry. The game is being updated continuously according to the games found. The list of games may be emptied by switching the active connection off (by setting the connection name to an empty text) and by opening the connection again. The searching will start from the beginning with the new address entered. Care is taken for the individual games listed to bear unique names. If two games bearing the same name are created, then the game names are numbered to characterize a game by its name unambiguously.
In the list of games only those games are visible that are created by the same program. To distinguish identical programs the identification is used which is derived from the main function
name of the program created in the Peter tool environment. A condition necessary for connection programs to the same game is thus setting the same name of the program main function.
The active game element is a text variable serving to create a new game or to connect to a game already running. The connection to the game selected is accomplished by selecting the game name from the list of games and setting the game active. By entering a game name not existing in the list a new game will be created. To distinguish, whether a new game will be created or if a connection to an existing game will be implemented, the fact, whether the game entered appears in the game list, is critical. Before connecting a game the list of games is normally loaded and one is waiting until the game required appears in the list. However, when creating a new game the list would not be loaded not to contain any game (The list can be emptied by closing and opening the active connection anew). If a game cannot be set active (if, for example, the maximum number of players has been reached), the element will return an empty text. An active game will be abandoned by setting this element to an empty text.
host (control computer)
The host (control computer) element is a logic flag indicating, if the computer in question is a control computer that has created the game and that the game is being run on. If the control computer leaves the game, then the game control will be taken over by another computer. The game take over is indicated by setting the above flag.
maximum of players
(0 = unlimited)
The maximum of players element is a numeric variable indicating the maximum number of players who can join the game. The value of 0 indicates an unlimited number of players (default value). This element can be changed by the control computer only. With the aid of this element the participation of further players in a game just running may be inhibited. After the game has been commenced the control computer will set the maximum number of players to the actual number of players participating in the game.
... numeric game parameter 1 to 8
(-16384 to +16383)
The numeric game parameter 1 to 8 elements are integral number variables ranging between -16384 and +16383, which can be utilized for setting the game parameters. The game parameters can be changed by the control computer only, other computers being allowed to read the variables only.
... game flag 1 to 8
The game flag 1 to 8 elements are logic variables serving to set the game parameters. The game parameters can be changed by the control computer only, other computers being allowed to read the variables only.
list of players
The list of players element returns a multiline list of players, who are involved in a selected game. Each player is assigned a constant ordinal number in the list. If a player abandons the game, his position in the sequence will remain empty (empty line in the list) until the position is assigned to another new player. Therefore the number of players taking part in the game may be lower than the number of lines of the players' list. The players' names are unambiguous. Should identical names occur, they will be numbered.
The active player element is a text variable serving to create a player after joining or creating the game. A player is created by entering his name. In case of a successful creation of a player the player will appear in the list of players, and this element will return the player's name. In case of entering an already existing name this name will get numbered. Returning an empty text indicates an unsuccessful creation of a player (the maximum number of players has been reached). By entering another name of a player after the player's having been created this player will be renamed. By entering an empty text the player will be excluded from the game. (Beware of entering an empty text by the user; the player could be deleted unintentionally).
active player number
(-1 = none)
The active player number element returns a numeric data representing the player's ordinal number in the players' list (numbered starting with 0). If the player is not created, the value of -1 will be returned.
data block send/receive
(-1 = to all/none)
The data block send/receive element serves to transfer the game data between players. The data reception is implemented by reading the numeric value of this element. If no data is received, the value of -1 will be returned. If a data is received, the number of that player will be returned who has sent the data. From this instant data is prepared in the buffer of the data received that can be read by means of data elements (see below) till exhaustion of the data or till reception of another data block. Before sending a data block the data is first stored in the output data buffer by means of the data elements. By quoting an element for sending a data block as a command having the target player number set the data is sent from the output buffer to the player selected. By entering the value of -1 in place of the target player number the data are sent out to all players of the game the same way as if no value were entered.
The number element serves to send and to receive a number between players taking part in the game. On entering the number this number is stored in the output buffer till sending it away. On reading the number this number is loaded from the input buffer. If there is no data more in the input buffer, the value of 0 will be returned.
integer number 0 to 255 (byte)
The integer number 0 to 255 (byte) serves to send and to receive an integer value ranging between 0 and 255 between players participating in the game. This number, occupying 1 byte (1 character) only, is suitable as to the low demand of the transfer capacity unlike a normal number, occupying 8 bytes. On entering the number it is stored in the output buffer till sending it away. On reading the number this number is loaded from the input buffer. If there is no data more in the input buffer, the value of 0 will be returned.
The text element is used to send and to receive a text between the players participating in the game. On entering the text it is stored in the output buffer till sending it away. On reading the text this text is loaded from the input buffer. If there is no data more in the input buffer, an empty text will be returned.
The flag element serves to send and to receive a logic flag between the players participating in the game. On entering the flag it is stored in the output buffer till sending it away. On reading the flag this flag is loaded from the input buffer. If there is no data more in the input buffer, a reset flag (the value of NO) will be returned.
Notes to the data transfer organization:
During the game a delay of the information transferred has to be provided for. This delay can reach units till hundreds of milliseconds. It can even occur that some pieces of information will not come in the same succession as they have been sent, or that they may even get lost. This matter of fact requires that the program might show some resistance against generating transfer errors. One of the applied methods of the game control is leaving the entire control activities to one of the computers (this is, as a rule, the control computer that has created the game). This deciding computer receives control information from the users of all other computers, makes decisions about activities to be carried out during the game, and then it sends commands to be executed by the other computers. The advantage of this central control mode is the unambiguous course of the game, the disadvantage is a lower game speed and higher demands for the data transfer between the computers. In addition, there is a problem consisting in the control hand over, if the control computer quits the game. Another possibility is to leave the decisions to each computer. Each computer thus informs the other computers about activities which were carried out as well as about all events concerning the particular computer. The matters in question may be for example the information about movements of own figures in the game, decisions about the hits received from the adversary, and the information about changes of the own score or about the figures' energy. The other computers carry out the inevitably transactions only, such as for example the figures' movement animation. The format of the data to be transferred is determined by the programmer himself during the program creation. A typical use is the data transfer in form of data groups. At the beginning of each group there is a number ranging between 1 and 255, representing the command code. The command is followed by command parameters according the own decision. The number 0 command represents the data end. This value being received automatically if there is no further data in the input buffer.
Full Html Context Help of The Peter - Gemtree Software & Children Programming