April is close to wrapping up and I was able to find time this weekend to type in another ZX81 game. Laser Blast, this month’s program, has you saving the world. Kind of cliché I know, but hey this was 1984. George Orwell’s novel didn’t come true, but at least we could blast alien’s with lasers. Use the Z and . keys to move and M to shoot your ray of death. But beware. The alien has a guided missile and it’s heading right for you.
Assuming you played a few rounds, you might have realized there are three distinct parts to the game. The first part, where you move towards your enemy to shoot it, is sluggish. In this part, neither of you is firing. You'd expect this to be faster, but it isn't. I’ll explain more about why this is slow later.
In contrast, when the alien fires at you, you can still move. Unlike the first part, your movement is fast and responsive. Too bad that missile is heading straight for you. Yep, if you’re in the wrong place when the enemy fires, you’re a goner. Oh, and you can’t fire either. This is what makes the game hard. But, as I later learned, there is a trick.
The third part is when you fire. If you’re over the enemy, you’ll just kill it. No explosions or such, but you will get a few points and everything spawns again for the next round. If, however, you miss, the enemy will keep moving towards you. Yes, if he is close enough he’ll run right into your laser. Oh, and he can’t fire once you do. Nice, huh?
When I first played Laser Blast again, my strategy was about balancing risk versus reward. As your laser shoots straight down, I incorrectly assumed that you needed to be over your enemy to annihilate him. So, when I played, I tried to guess when to get close so I could shoot him from above. This makes the game very difficult, especially as I ramp up how often the alien fires.
Yet, once I realized that the alien would move towards your beam as you fire, my whole strategy changed. Now, I just had to gauge about the distance needed to successfully kill the alien. I could hover just inside within range for the alien to move into my laser. If the he fired first, I was usually far enough away that I could still escape his missile.
What I first thought was an impossible game now became much easier. A balance issue with the firing mechanics was became a problem with how fast the alien moved towards your laser. If I wanted to go back and improve the games balance, I could have done two things. I either needed to slow down how quickly the alien moved, or provided him the smarts to dodge your laser. The difficulty still ramps, allowing the alien to fire faster. But with the right strategy, you can still max out the score.
Graphics wise the game works. The elements are simple but easy to recognize. You figure out where you are pretty quick and your laser looks, well, like a really big laser beam when you fire it.
Your enemy moves along a digital floor which nicely divides the screen. Down at the bottom, Laser Blast displays your score and number of lives left, the sexist “men” of the era. The enemy’s missile track you, leaving trails that look quite nice.
I actually like the way the laser and missile move one way, then roll back to erase it. It’s a nice effect that gives the game some character. I also liked the nice juxtaposition that contrast the two styles of weapons. The straight line of your laser, with the zig-zag of the alien's missile.
The game also does a good job of displaying text. Although I wouldn't recommend using blinking text today, back then it looked good. The flashing words were simple animations that stood out against another flat world. I could have used some more text here and there, but what is there is clear and easy to understand. Centered and well placed, Laser Blast does text right.
That said, I could have improved a few things. There is no grand explosion when you shoot the enemy ship. And, vice versa, there is no wreckage when you die either. You just spawn again with one less life or a nice new enemy. Although the animation or text would have slowed the game down, it would also have made things clearer.
Game Play Coding
This time around, the code is pretty straight forward. There are no
POKE’s here. The BASIC is mostly straight forward stuff. Yes, I peppered it with my normal dosage of boolean logic. But that’s as complex as it gets.
There is a good amount of math though. The variable Q determines how often the alien will fire at you. As you shoot him, I lower its value a little, which makes him shoot more often. Q stops lower after it gets to 0.5, assuming your score is still less than 7000. If above that, Q can drop as low as 0.3, or about a 2 in 3 chance of firing at you each move. By this time, things start to get pretty hard.
To increase the difficulty even more, I added another change when you hit 2000 points. Up to that point, everything spawned in the same place. After a score of 2000, the enemy will randomly spawn on the ground. Given that he is now firing more often as well, a bad spawn could mean instant death. You will need a quick trigger finger when this happens to avoid instant death.
One thing I liked, though, was that I was thinking about fairness. Every 1000 points, Laser Blast grants you another life. Sure, it limits you to seven, but at least I was trying to be nice. Most of my games just gave you one chance before it was game over.
Oh, and if you hit 10,000 points, the game ends. It was kind of like you rolled the counter and that was as far as you could go. This is an artificial limit as the ZX81 can display larger numbers. But it gives you something to shoot for, no pun intended. When you do hit this limit, Laser Blast displays a different ending. If you’ve read this far, you can surmise the optimal strategy needed to hit that magic score.
Speaking of Sluggish
So let’s talk about that sluggish part of the game. I’ll start by reminding you how bad the ZX81 is at printing numbers. No really, it just plain sucks. You should avoid it at all cost. Not only did I print one number each turn, I printed two. In fact, I don’t change those values during this section either. I could have broken up the PRINT routine on-line 140 into two lines to gain back some speed.
The other problem is that I structured the code wrong. Because of this, I introduced a slight delay in the loop when I jump over code. These three lines illustrate the problem:
160 IF INKEY$="M" THEN GOTO 180
170 GOTO 260
380 GOTO 140
On reaching a
GOTO, ZX81 BASIC scans through he program to find the right line number to execute. This slows things down, especially if the line number is deep in the program. Although it didn't have to go too far, I should have avoided jumping this section of code. But, there is a reason I did. I wanted to allow the alien to move after you tried to fire at it. But this is minor issue that, having done it a different way, I could have accomplished while masking the latency.
The parts where you or the alien are firing are fast because of what they don’t do. For one, they don’t display unnecessary information, such as the score and ground. And, because I wrapped them in a
FOR loop, the code doesn’t have to scan through the program to find the next line number. Instead, the ZX81 uses its stack to keep track of the start of the loop. Combined, these routines are fast and responsive.
One other minor thing, when you die I don’t update the display. Because of this, your ship's location or number of lives displayed could be off. This is a minor bug, but it is annoying when it looks like you weren’t hit or still had a life left when, in reality, that wasn’t the case.
I did make one change to the code. When you die, or happen to be good enough to beat the game, you could still be pressing a button. This could trigger the game to restart before you’ve realized that it is over. To prevent this, I make sure you aren’t pressing a key first. It doesn’t change how game plays. I just didn’t want you to skip past the end without realizing it.
And there you have it. Laser Blast is a game that looks easy, but it is deceiving. As the score ramps, the game gets more difficult. But, with the right strategy, playing can be quite fun to play. It isn’t perfect, though. Perhaps I’ll find time to improve it. Or, perhaps I’ll just leave that for some other adventurous soul.