How to playThis part is so simple it doesn't really warrant any explanation. Shoot ateverything that moves and some of the things that don't. You'll soon learnwhich objects can be blown up and which ones just absorb the blasts. Avoidflying into anything that looks bulky and sticks out of the ground.
Keep in mind that most Java-enabled browsers require that the cursor islocated within the current applet area for the keyboard input to be directedto the applet. Some may even insist on an initial mouse click.
How to cheatI didn't spend weeks preparing the graphics of Warp just to have them gatherdust because most people are too lousy players to get any furtherthan level one. You can start any of the first five levels by pressing theSHIFT key plus A, B, C, D or E.
Platform-specific problemsOn certain machines with slow graphics cards but fast processors, the"curtain" effect between levels and when losing a life will not look right.It will appear to take only two or three steps before the screen goes blank.This is because the main loop has a period of no less than 70 millisecondsand the computer can't redraw the screen that often, so it will simplyignore the update request and wait for the next one ... or the next after that.However, during actual play, the loop has a lot more to do and will usuallybe delayed for so many extra milliseconds that the computer doeshave time to carry out the updates.
Technical stuffAlthough each level is more than ten screens long (and can be made any size)the graphics area that stores the background is in fact just a little overtwo screens. Think of the current view as a window that moves upward along thegraphics area. New ground is continuously being drawn above the window. At thesame time an exact replica is drawn below it, so that when the windowreaches the top of the graphics area it can jump down to the bottom andcontinue seamlessly from there. The cost of this on-the-fly graphics updatingis (at most) one
Graphics.drawImage operation per animation cycleand it saves a tremendous amount of memory.
Another memory-saving strategy I've used in Warp is to load the graphics ofeach new level separately and throw them away when they are no longerneeded. This dramatically cuts down on the number of
Image objectsthe applet needs to allocate and of course reduces the download time fornetsurfers who weren't going to play all nine levels anyway. (I was actuallyforced to do this because the game would have been too big to run onmy humble Macintosh Performa 6200 otherwise.)
To make the scrolling as smooth as possible, I don't update the score displayand the blasted stationary objects immediately, but wait until thegraphics updating has a spare cycle. I'm not sure exactly how much effect thishas, but on slow machines I suppose every little bit helps.
IngredientsWarp needs ten graphics files - one for each level and one that holds theparts that make up the control panel and the things that remain constant ateach level, like explosions. They are named
warp9.gif and can be found in the current directory. The gamealso needs sounds. KA-PEOOO!, CRASH! and BING! comein individual audio files named
Source codeThis is what the code looks like.
Back to the game.