 |
Cross Section: Technical stuff
|
 |
The rotational effect is not as complicated as it may seem. I've got eight
300-by-15 pixel brick segments, slightly shifted with respect to each other,
so that when they are animated cyclically, they appear to be rotating
sideways. (I create these segments from the single brick in the graphics data
for each level. It takes a lot of pixel manipulation and
projection, but that's not really important in this context.)
The most straightforward way of getting the tower to look right would be to
prepare several different backgrounds, made from the brick segments, and
flip between these during the game. I discovered, however, that if I tiled
the segments in a slightly spiraled manner, I could get by with a
single background image barely 2 1/2 times the size of the playing area,
provided I'd later give it the proper vertical offset.
I won't spoil the fun for you if you want to deduce the mathematical formula
yourself, given a viewing angle and the height of the window. Otherwise
you can find it in the applet source code.
Of course, all the ledges, windows and other objects have to be treated
separately. During initialization I prepare lists of all the geometrical
data the applet will need to draw things in their proper positions, so
that there is no need for processor-intense sine and cosine evaluations
while playing.
What's left to do, in terms of graphics, during each game loop cycle is this:
|