The pong module provides a pong game on demand. There are two potential operator connections - one for the left player and one for the right player. The game starts as soon as the first player joins. In case only one player is in the game, the other side is played by the computer.
The configuration of the pong module with name NAME
is located in the pongs/NAME
subdirectory.
The colors of the different element of a pong field are configurable. All of them are given in web notation, i.e., as 6 hexadecimal digits - 2 digits for read, green and blue. The color is automatically converted to the selected format (i.e. number of channels and number of colors). Each color is defined in the appropriate file. If the file is missing or contains an invalid color code, the respective element is not drawn on the frames. The following color files exist:
file name | element | |
backgroundColor |
background of the pong field | |
ballColor |
pong ball | |
computerColor |
pad played by the computer | |
goalColor |
game score when a goal has been scored | |
lineColor |
line in the middle of the field | |
padColor |
pad played by a real player | |
scoreColor |
game score when the ball is moving |
The file delay
describes the duration of a frame / a step
of the game.
It contains a number that specifies the time in milliseconds.
Valid values are from 100
to 500
.
In case the file is not present, a default of 200
is used.
Please note that the game speeds up a little bit when the ball bounces
a pad and when a goal is scored.
The file format
describes the format of the canvas,
i.e. its dimensions, the number of channels and the color depth on
each channel.
The file must contain a string
<width>x<height>-<channels>/<colors>
,
e.g. 18x8-1/256
for 18 pixels width, 8 pixels height
in 256 grayscales.
The file maxScore
configures at which score the game ends.
The file contains this maximum score as a number.
Valid values are from 1
to 99
.
In case the file is not present, a default of 9
is used.
The file outstream
contains the name of the stream to
send the frames to.
No frames are sent when the game is inactive (i.e. no player has
joined yet).
It is possible to request playing a sound on certain events occuring during the game. The names of the sounds to play are configurable via the following files:
file name | play sound on event | |
leftPlayerSound |
player entered the game as left player | |
rightPlayerSound |
player entered the game as right player | |
scoreSound |
player scored a goal | |
otherScoreSound |
other player scored a goal | |
winSound |
player wins game | |
looseSound |
player looses game |
The name of the operator connection interfaces provided by this module
is the module name plus the side of the player. Thus, the operator
connection interface for the left player is pongs/NAME/left
and the one for the right player is pongs/NAME/right