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:

The first step is to compute the proper vertical offset for the big brick image and draw it on the playing area. Then it's time to search through the internal lists of ledges, windows and other objects, to determine which ones are within the visible region and need to be drawn. The windows are drawn first. The rest get stored in a special list, for the moment. Then the applet sorts the list of visible objects in order of "depth", so that the ones far into the tower are first. Finally they are drawn in that order on the playing area, which is in turn displayed on screen.
This is repeated approximately 12 times per second. Even computers running at well below 100 MHz seem to be comfortable with this speed and things move reasonably smoothly.