April’s Program: Flywheel
Avoid oncoming cars in this night time driving game.
April has been a crazy month. I decided to try something new, pushed along by an unexpected event. I’m writing a book. I joined NaNoWriMo just after last November's event so I didn't expect to do anything until later this year. The surprise was there CampNaNoWriMo event in April. Not to waste the opportunity, I’ve been busy crafting my Sci Fi novel and am now in the final stretch to my 50,000 words goal. Add on top of that a business trip and a family trip and you'll quickly see that my ZX81 hobby gets pushed by the wayside.
Not wanting to skip a month, I decided to dig into my past and present a program from my first ZX81 site. This April I present Flywheel as the program of the month. It is an easy to play racing game. Just dodge the oncoming tail lights using the “Z” and “.” keys to move left and right. Take off from the starting line, pass the cars, avoid the curves, and have fun! You'll rack up about 500 to 1000 points per round. How high a score can you achieve?
I really like this game! It's one of the later ones before I became a C-64 owner. It’s loosely based on the Atari game Night Driver. Since The ZX81 didn’t come with a paddle the car moves a bit slower and being written in BASIC doesn’t help. That said the game is pretty responsive, but could be improved using MCODER II. Sadly, I’d have to rewrite most of the code to do that. Perhaps something I might do after I finish my novel. Even in BASIC, the mechanics and graphics are pretty good for what it is. I did change the program slightly from the original to fix overwriting part of the curved track when the car starts too far over. I also fixed a tail light animation that was in the wrong place. Again, fresh eyes always see ways to improve an old program. I also see many places I could have shrunk the code.
Talking about code, Flywheel is a fun program to study. If you’ve read other articles of mine, you’ll find that this game uses pretty much every trick in the book. You’ll find array animation, loops of every kind, GOSUB
's using math, boolean math used to replace IF
statements, etc. The track animations are the most interesting. You’ll notice that they display two rows at a time. The curves, keeping the same look, has the entire track in one line but uses AND
’s to decide which rows to print. I’m pretty sure I originally was going to use these routines to print over the tail lights. In the end, it was faster using the GOSUB
math to animate their movement.
Until next month, enjoy!
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.