Well, hard to believe we are turning the corner on March and heading into April. Spring is edging its way in and it is time to get outside and work in the yard. This made me want to kick my ZX81 program to the curb, but it didn’t feel right. So, I bundled up my current progress on Run.
# Pixel movement.
In this next iteration of Run, I wanted to see if I could get the sky to move a bit smoother. The idea of moving a one pixel at a time intrigued me. Now, I had two potential options. One would be to flip bits. That is, shift the pixels in each block. There are some ways to do this involving some bit math and lookup tables. However, I decided the effort was a bit more than I wanted to take on.
Instead, I went the second route using two different images. Each was an offset of the other. I created a simple variable to flip each frame and used it to decide which image to display. The routine was easy, just burns up some memory. But Run is a pretty small game already. The final result was a nice, smooth animation of the sky.
Run 2 ML, ZX81 Screenshot, 2022 by Steven Reid
The drawback is that I lost my use of the hatched or gray blocks. A small price to pay for a more interesting sky. This was where I had planned to end my hacks, but for some reason I decided I wanted to keep going. I needed more sky!
# Worlds to play with.
This led me to my next bit of work. I supplied out a few more skies. In the current version, there are four. I also played around with the sun in each, moving them to different positions and adding a moon to make things interesting. The final says flow nicely and I think they will fit the game look well.
There was, however, a minor problem. Seems when I swapped in the new sky it caused some blinking of pixels. Seems that transition is a bit of a problem. I needed to overlap the pixels a bit from the old to the new sky. Again, taking an easy route, I just replaced that pixel when I swapped in the sky.
Run 2 ML, ZX81 Mountain Screenshot, 2022 by Steven Reid
To make it all modular, the game uses a simple array with addresses and the aforementioned transition pixel. This made it easy to play around with different sky orders, add in new ones, or even repeats them if I wanted to.
# Ringing up a score.
With that done, I had in my head an idea of how I wanted the score points. My vision was a score that appeared and trailed off and disappeared. Now the ZX81 doesn’t make that easy. With only two colors at my disposal, I decided to cheat. I started with a bold, inverted scored. That moved for two frames. I then flipped to normal text for the next two frames.
To my surprise, it looked just right, matching what I had in mind. The score popped on screen, and floated up into the sky. Even more surprising, I got the values right the first attempt. The programming gods were looking down on me that day.
# Fixing some slowness.
With all the changes, I found that using the ZX81’s native print routines wasn’t the best idea. To speed up the sky, I switched to using direct manipulation of the ZX81’s display table. This is pretty easy, as I might have done a lot of that working on Gem Quest. Fixing it really sped up the routine and I had a pretty smooth animation.
With the new score, it was still a bit slow. To compensate, I adjusted the frame counter a bit to allow time to add in the new display element. I’m still not perfectly happy with the speed. I’m concerned when I start adding in obstacles and player animations, it will be too slow. I’ll need to optimize these routines a bit more.
Overall, though. Run is shopping up to look like a decent game. I’m still thinking about flipping the score to the other side of the player. As I add in obstacles, I’ll need to ensure the frame rate doesn’t change depending on what is displayed. Things I can work on in the future.