August’s Program: Cave War
Try to escape the cave in this ZX81 scrolling game.
August’s program is Cave War, a later program from 1985. It starts out similar to Hit Man, basically a scrolling dodge the wall game. But there is more to it than that. Once you get to the end of the tunnel, you find yourself in a cave and need to blast away at a wall to continue on. Oh, and if you hit the same spot twice, it resets. Can you make it out of the cave alive? Use Z and . to dodge the walls and X to blast away the ground. Good luck!
Cave War was probably inspired by a popular Atari game at the time, Caverns of Mars. Inspiration aside, dozens of games used wall dodging as the basis for their games. The ZX81 actually makes this easy. There is wonderful SCROLL
command that moves the screen up one line at a time. Sadly, it isn’t implemented very well. The command has a sync issue that causes the screen to bounce which is pretty annoying on a real TV, or a good emulator. That said, it works okay and doesn't distract too much.
The cave attack is actually the best part of the game. Sure I wrote it, but I really enjoy the way the room scrolls in. The moving wall and shooting mechanics work well. To keep the speed going, I don’t bother printing any shot. It just changes the block on the wall. The wall moves in spurts so it feels more responsive than it is. The fact that it breaks up the normal wall dodging mechanics adds a lot to the game.
I did make a minor change to the cave section. Originally, you needed to blow away twenty of the blocks. I found that almost impossible, especially if you drop into the room in the middle. I simply dropped the number to ten, which you shouldn’t have any problem getting by. If I wanted, I could have made it a variable that increments and worked to find a balanced limit. That said, it’s good enough for what I was trying to do.
The game loops forever, but the transition is pretty interesting. This time, you have to navigate a smaller tunnel. The game prints the tunnel opening over the bottom part of the room, allowing you to escape as the room scrolls up. It makes for a nice effect.
Interestingly, I store the tunnel as a variable and swap it each round using boolean logic. I’m sure I did this because it printed fast, but it looks cumbersome. Check out line number 380 to see what I mean. It works though and sometimes that is all that matters.
The rest of the program is pretty straight forward. I did use VAL
to pull the screen character to detect a collision. Oddly, I only use it once so I’m not sure why I took the hit and didn’t just put the code in the IF statement.
The wall is a string variable. Much like I dealt with the tunnel, line 280 shows how I used boolean logic to swap the character in the string. The next line then checks if it is a space and, if so, increments your score. I actually don’t check if you cleared the wall until the loop at line 340. If you hit too many spaces and converted them to dollar signs, you might actually lose that round.
Overall, a decent BASIC game on the ZX81. It has a lot of potential and just typing it in I thought of a couple of improvements and ways to just convert it to MCODER to speed it up. I really should quit doing that.
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.