manual.html

# Free Tennis

## How to play

This is a tennis simulation, not an arcade. You play with the mouse and five keys. Five keys may seem overwhelming, but you can play very well with no keys at all! The keys are meant for experts (e.g. to change the shot height, to sprint, to dive, to do backspin), and can be learned to use gradually. The five keys are X, Z, D (on the keyboard) plus the two mouse buttons.

The meaning of mouse movements and buttons depends on the "game phase". We can identify three game phases:

1. service phase: your player is serving;
2. feet movement phase: in this phase the mouse controls the feet of your player;
3. aiming phase: in this phase you use the mouse to aim (i.e. decide where the ball will fall), while the feet of your player are controlled by the A.I. You can tell you are in aiming phase because you see the shot parabola (see screenshots).

The meaning of controls is the following:

### During the service phase

The meaning of the mouse movement is the following:

- right and left movement: changes the direction of the service. Up and down movement: does nothing.

The meaning of the four keys is the following:

- left mouse button: play a first service (powerful)
- right mouse button: play a second service (sliced, slower and more safe).
- other keys: they do nothing.

### During the feet movement phase

- mouse cursor: controls your feet. So, for example, if you move the mouse to the right, the player will take a small step to the right.

  Please note: the mouse does not control the speed of your movement, only the direction. The speed of movement is fixed and depends on the chosen player (though it can be increased temporarily by sprinting --- see below). So, moving the mouse a big amount won't make your player move faster.

- X: sprint. By sprinting, you increase a lot the speed of movement, but you decrease the ability to change the direction of movement. Sprinting is fundamental to approach the net quickly.

  Here is how it works: when you press X, the current mouse direction is locked, and the player starts sprinting in that direction. As long as you keep X pressed, you can alter the running direction only slightly, by moving the mouse. When you release X, the sprint ends, and you can once again control your feet fully with the mouse.

  Note: sprint energy is limited: it is just enough to help you take the net when starting from the baseline. So, use it sparingly. The yellow bar to the right side of the screen tells you how much sprint energy you have left.

- D: dive. Only for experts. Your player will dive left or right (the direction is chosen automatically). You should only use "D" under net, to catch a passing shot you can't reach otherwise.
  As a visual aid, sometimes your player turns yellow. Yellow means "if you press D now, your dive will succeed". In other words, yellow means you are in case (2). Pressing "D" when your player is not yellow is useless: you will miss the ball.

### During the aiming phase

- mouse cursor: controls the place where the ball should bounce.

- left mouse button: decreases the height of the shot over the net. Note that decreasing the height makes the trajectory more straight, and therefore it makes the shot faster (since the gravity is constant). Decreasing the height is very important in passing shots because, if your shot is low above the net, the opponent will be unable to play a powerful volee.

- right mouse button: increases the height of the shot over the net.

- Z: change the spin of the current shot from topspin to backspin. This key must be pressed before the player has begun the shot gesture. If the gesture has already begun, the key does nothing.

- other keys: they do nothing.

## Other keys that work during game

Note: as soon as the game starts, you need to press either "F" or "G"
to activate mouse input. See below.

- F : Enter fullscreen mode and start listening to mouse input. Press again to exit fullscreen mode.

- G : Hide the mouse cursor and start listening to mouse input. You only need to press this in order to play in a window, without entering fullscreen. Press again to release mouse input.

- I : increase the average camera height. Use this to have an eagle-eye view.

- K : decrease the average camera height. Use this to make the game more immersive.

- ESC: exit the game

- -: decrease the game speed (slow motion, useful for newbies)

- 0: increase the game speed.

- P : pause the game.

## The players

Currently, you can choose among 3 players: Pete, Mats and Ivan. The following descriptions are only valid if you enable the "-realistic" flag (see below).

- Ivan. Powerful groundstrokes. Heavy topspin (curved parabola) and therefore good angles. Fast. Weak at volee.
- Mats. Not powerful but very precise groundstrokes. Very heavy topspin (curved parabola) and therefore very good angles. Very fast. Average at volee.
- Pete. Powerful at groundstrokes, but not precise. Flat strokes (flat parabola). Average speed. Very precise at volee.

## Command line options

The game must be started by command line. The minimal command line is

    ./freetennis -newbie

which will start a human-vs-computer match, on cement, with players equal to Ivan and Ivan.

### Choosing the players

You choose the player with the -p0 and -p1 command line options. For example:

     ./freetennis -p0 ivan -p1 pete

The default is "ivan". Case does not matter.

These options are ignored when the "-client" option is used.

### Choosing the court surface

You can choose among three surfaces: Clay, Grass and Cement. [insert descriptions here].

You specify the court surface with the option -surf. Example:

    ./freetennis -surf cement

The default is "cement".

This option is ignored when the "-client" option is used.

### Playing human vs computer

This is the default. You don't need to pass any special option to start a human-vs-computer match. Only, remember that player 0 is the human, player 1 is the computer.

For example, if you want to play with Ivan against Pete, type

    ./freetennis -p0 ivan -p1 pete

and the computer will impersonate Pete, whereas you will impersonate Ivan.

### Playing human vs human

In order to play human vs human, you need two PCs connected via a network (either LAN or Internet). One of the PC must act as a server, the other as a client.

The server must be started this way:

    ./freetennis -server -port yyyy

where yyyy is a free TCP port in your network (e.g. 8080). The port must be chosen according to which ports your firewall makes available.

The client must be started this way:

      ./freetennis -client xx.xx.xx.xx  -port yyyy

where xx.xx.xx.xx is the IP address of the server (e.g. 192.168.1.33), and yyyy is the same port specified by the server.

The option "-port" can be omitted, in which case a default port of 4000 is used. You may have to configure your firewall to open that port. The client does not have this problem.

In human-vs-human mode, the players and surface are decided by the server. The -surf and -pXname options are ignored by the client.

Example: in order to start a match Ivan vs. Pete, on the grass, you should type

    ./freetennis -p0 ivan -p1 pete -surf grass -server -port yyyy

on the server, and

    ./freetennis -client -port yyyy

on the client.

### Making the game realistic

In this section we'll talk about the "-realistic" and "-newbie" flags. These flags are mutually exclusive, and you must specify one of them (there is no default). Their meaning is the following.

In real tennis, these 3 rules hold:

1. players who are powerful are usually not precise, and viceversa;
2. some players are more skilled at net, others at groundstrokes;
3. fast shots are more difficult to respond to.

So, for the game to be realistic, those rules must somehow hold; that is, aiming must be more difficult if the opponent's shot is fast, if you are not very good at that shot, or if you are very powerful.

This happens when you choose the -realistic flag. If you use it, the parabola becomes more or less visible, according to the situation, so as to satisfy the 3 rules.

The -realistic flag makes the game much more amusing, but also more difficult for newbies (it is more difficult to aim). So it should be avoided when learning (in which case you should use the -newbie flag).

Note: without the -realistic flag, some players are much more convenient to use than others. With -realistic, each player has its own strength and weakness, and the game is more fair.

### Choosing the difficulty level

This only makes sense if you are playing human vs computer. The option to use in this case is -computerskill. Example:

    ./freetennis -computerskill 200

The number must be between 0 and 250. 0 is very difficult, 250 is very easy.

### Choosing the resolution

Use the options -xres and -yres. Example:

    ./freetennis -xres 400 -yres 300

### Miscellaneous examples

    ./freetennis -realistic
    ./freetennis -p0 pete -realistic
    ./freetennis -p0 mats -p1 ivan -newbie
    ./freetennis -surf cement -computerskill 200 -realistic
    ./freetennis -client 192.168.1.33 -xres 400 -yres 300  -realistic
    ./freetennis -server -p0 ivan -p1 ivan -surf clay -realistic -nosound

## Miscellanea

- Sometimes your player turns red. This means "I can't reach the ball, it is too far". In this case, all you can try is sprinting (with the appropriate key, see above). If, by sprinting, you can get close enough to the ball, automatic search will start. But this is not guaranteed: sprinting may not suffice if the ball is very far (and this happens most of the time).

- There is no tournament mode. Only single matches. And there is no doubles.

- The match does not end until you press "ESC".

- In the future, more players will be added, and each player will have his own visual gestures.