Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
How difficult would it be to add a chase car that chases the car controlled by the keyboard? The chase car will need to automatically steer itself to catch up with the user controlled car. We will use a simple chase algorithm for the chase car. If the lead car is to the left of the chaser, the chase car will turn slightly to the left. If the lead car is to the right, then the chase car will turn to the right.
The only additional element we need is a new controller. Example 12-31 shows the IChaseHandler interface that defines a chase algorithm based on timer events. It also declares a method to set the chase target, which is of type ICar.