For February, I give you Time, a simple landing game with a twist. Using the Z and . keys, you maneuver your craft to each successive landing pad. If you miss the landing, keep trying but be careful. Run out of time and itís game over! How high of a score can you amass? A fair warning, Time isnít always fair.
Digging into the program, letís start with the twist. A counter a the top tells you fast you are landing. If you miss the platform, you can keep trying as long as the counter is less than 1000. To add a bit more stress, the timer runs faster each successful landing, starting at 10 and going as high as 60. Beware, at the largest increment you'll need to stick the landing on the first try. The name makes more sense once you understand how it impacts game play.
While looking at the code, the first thing I noticed is that I implemented the timer as a string. Iím not sure why I did that. I donít do anything interesting with it, it is just a counter. The only thing I can think of is that the ZX81 is slow when printing numbers and I was trying to work around that using a string. However, because I have to use a number of math functions to increment the counter, specifically
VAL, I actually lose any speed improvements. I wrote a quick test program that counts to 20 using the two different methods to see how they compare. It took 10 seconds using a string variable compared to just 9 seconds using a regular variable. Fortunately, that isn't enough difference for you to notice while playing. It does, however, make reading the code more fun.
If youíve played the game, you will find that it is wildly unfair. The landing pad is randomly placed each time at the bottom of the screen. Your shipís position carries over from where you landed last. You will at some point find that yourself on the opposite side of the screen from the platform. This is a bit of problem as the screen is wider than tall. You just can't move fast enough to reach the landing pad. For the first few rounds, this isn't an issue. You can just miss and keep moving to reach it. At the greatest increment, however, the timer will always be greater than 1000 when you reach the platform. This makes it impossible to land in the situation above. You could easily fix this by reducing the largest increment to 50. Given this is really the only challenge you face, I left it alone.
I did make a couple of changes to reduce confusion for those not familiar with the ZX81. The original program stopped once you failed to land. I changed the
PAUSE 4E4 and added a
RUN command to make it go forever. There are also a few lines to save the program and make sure it will run automatically on load.
Overall, Time is a fun little program. It is pretty easy to read and has some interesting code, if not really needed. I wish I knew what I had intended with the counter, it might have made the game a lot more interesting to play. Perhaps this idea, like many others, will find its way into future programs.
If you want to run this program on your Android phone or tablet you can download a compressed copy of the program to your device. Youíll need to save the .p version of the program to your device to allow Zed Ex (Beta) to run it.