Try Not to Crash the Moon Lander in This ZX81 Game
My take on an old moon lander text game.
When I first started programming, one of the games we would play on the old teletype machines was a simple moon lander game. The premise is you would use your thrusters to softly land on the moon. Moon Lander was my take of that program a few years later.
A trip down memory lane.
I actually enjoyed playing Moon Lander. The original game had a pretty simple design. It had three basic parameters: speed, fuel and thrust. You decide how much thrust to apply, and in turn how much fuel you burn. The original program was turn based, where each turn you would decide how much thrust to apply. The game would then print out your speed and fuel available. To be successful, you needed to watch your acceleration and make sure you didn’t run out of fuel.
In my ZX81 version, it is somewhat similar. Your lunar models is accelerating towards the ground and the game prints the speed in the corner. If you can land with 1.2 or less speed, then you succeeded. The catch, you have to get to the landing spot. Unlike the older text only game, I tried to add a little arcade action. And it works.
Not so easy.
The game isn’t the easiest, but that actually is a good thing. Loading it up to play it again, I was surprised how much fun it was. It didn’t take too many attempts to land successfully, but that doesn’t mean I was good yet. I did get into a rhythm at one point, landing multiple times in a row. Sadly, it didn’t last. I’m not complaining, though. That is what makes a game fun.
Now, the graphics aren’t as great. The game isn’t slow, but does flicker a bit more than I prefer. There are a few graphical glitches as well, such as the landing pad being hard to see sometimes. But those don’t detract from the overall game. Sure, it isn’t perfect, but it isn’t bad either—especially in the context of when it was written.
Some interesting code.
It is always fun looking back on my old code. I can usually tell how things changed as the program developed. Most of my programs use lines numbers that increment by ten. For example, 10, 20, 30, etc. In this case, there are a number of lines that are in between those. That is a clue that I added them as the program developed.
I usually have a plan in my head as I worked on the programs. Occasionally, those ideas aren’t fully baked. In this case, I could tell that I added some of the game elements afterwards. That seems to be the clearing of the screen between moves and printing the speed. The speed is pretty important as it helps give the player an indication how they are doing.
There are a couple of interesting things I hadn’t seen in other programs of mine. The first is the the C$ variable. I used a DIM
to set it, which clears it with a space by default. It’s actually a rather clever bit of code. I’m surprised I didn’t use it before.
In a similar vein, I used a STR$
before printing the speed. The ZX81 uses floating point numbers which are notorious slow. The STR$
command will convert a number into string like it would look if printed. This is a useful command, but not usually in this context. I’m sure my thought was it would be faster or less jarring than just printing a number. Printing a number is pretty slow already, so I can understand why I was trying something new. In my testing, I don’t see any difference. But was interesting to see the attempt.
There was some other code that was interesting to see. There is an F$ variable that is set and tested within the code. I’m pretty sure that was meant to manage fuel, the other attribute of the original game. However, I didn’t see anyplace where I actually adjust it. It must be one of those ideas that I started to work on, but just never implemented.
A lot of opportunity.
Although the game is a lot of fun, there is a lot of opportunity to improve the game as well. I really want to reduce the flickering. I have a couple of ideas of how to correct that. Part of that is removing that large array.
The other problem is the landing pad. It is hard to see sometimes. I found myself getting lost at times figuring out where the ends were. A simple fix is to use different characters that make it easier to identify the landing zone. That might not be realistic, but this is a game after all.
The biggest change, though, is to make the speed more visual and remove the number. This had two advantages: speeding it up, and making it easier to see what your speed is. At the same time, making the file work and also display it would add another element to the game.
The game surprised me, not expecting it to be that exciting. Given that, I’ve already started work on the changes above. I’ll share those next month. I also feel this would be a good game to convert to assembly as well. I think the speed would really improve the game’s flickering and maybe allow for some additional features. But that idea is for the future. Enjoy the game for now.