Tour de Applet: Technical stuff
The scrolling background essentially works the same way as in
Warp 1.5, except that the vertical pixel
increments aren't constant. The new algorithm can handle anything from 1 to 8 pixels
per step, corresponding to the full range of possible bike speeds.
Just like in Warp and Warp 1.5, the
background is made out of block sections that are 32 pixels high (illustrated with
white lines in the picture). The pieces that make up each section are somewhat
irregular. I don't want to give too much away, but everything outside the road
comes from graphics data files looking something like this:
The leftmost part is a 32x32-pixel tile and the rest are decorations of different
sizes. At first glance the bushes, or whatever, appear to be randomly strewn about
in the terrain, but there are in fact exactly two of them within each 32-pixel segment.
This would be obvious if all decorations had the maximum 32-pixel height. The
inclusion of smaller ones helps fool the eye.
The competitor bikers needed a fair amount of
artificial intelligence to successfully avoid the obstacles (well, most of them).
As always, this is an illusion. Each road section can have at most one obstacle,
and for every section I create I compute the horizontal center of the widest
available gap (shown as black 'x's in the picture to the right). A competitor biker
accelerates horizontally towards the 'x' position roughly two sections ahead.
Normally this rule is enough to guide him safely through the track.
Collision detection is also relatively simple, but it works. Road sides and bikes
are approximated by straight lines. Obstacles are approximated by rectangles.
The rest is just geometry and linear algebra.
To minimize the number of image drawing operations per time unit, each object has
a built-in shadow (a check pattern of black and transparent pixels, which at a
distance looks like a darker version of the color beneath it). But this shadow must
not be allowed to cover any other object. Otherwise that object would look flat. So in
each animation frame I sort all mobile objects in horizontal order and then draw them
from left to right. Then the shadows will only fall on the ground. While this is not
100% accurate, it looks more believable than the alternative. The only exception is
when the bikes or bikers go flying. Then the shadows are drawn separately (and always
before the other objects).