For some time now, I’ve wanted to build a running type game. The kind where there is a single key to press and releasing it makes you take an action. There are lots of variations on this theme, and it seemed like something fun to try. Idea in hand, I began by building out a rough look for the game.
# Start simple.
I really wanted to have some sort of movement in the world. My head was swimming with different ways to accomplish that. I had visions of parallax movement, jumping, and all sorts of other crazy ideas. The problem was one of finding one to see if it would even work.
Forcing the ideas out of my head for the moment, I started by sketching out the running animation. Given this was a key animation to the game, it seemed like a fitting start. I started by sketching out my initial frame. This game me a feel for the scale of the runner. From there, I began to map out each frame of the animation.
Given the low number of pixels i was working with, I didn’t like the squashed look when the legs crossed. I tried multiple styles to see what might look better. I even did each leg and arm separately and then overlayed them to see if that would improve the look. In the end, I ended up with a four frame pattern.
Out of the four frames, only three are unique. I also sketched out a starting position, but didn’t use it in my testing. I still need to work on the jump routine to complete the game. Although, I could just use the first frame when I get to that test.
# Time to test.
With my frames complete, I needed to see how the animation looked. Since I was only printing a few frames, I decided to build a quick and dirty ZX81 BASIC program to test. I loaded each frame into an array and then just looped over it. Not bad, although it may be more of a walker than a runner.
Not content with just having just the player, I worked on a two line sky. I wanted to have some sort of parallax effect in the game to make it feel like you were moving. For the test, I created some simple clouds with sun that would sit above the player.
To animate the sky, I used another array. I wrote a straight forward rotate function to shift the first character the end of the array. I made the array a bit longer than the screen to hide the rotate. The final animation worked pretty well, even in BASIC.
Run Test, ZX81 Screenshot, 2022 by Steven Reid
Although the test worked well enough, I knew it wouldn’t be fast enough for a game. The sky animation was already staggering a bit. I’m sure I could clean that up a bit, but adding objects and a jumping routine were going to bog down in BASIC.
# Speeding it up.
This led to me converting the BASIC into a z80 assembly program. Fortunately, it wasn’t difficult. I think I spent more time setting up the assembly file than writing the routines themselves.
I followed pretty much the same pattern as I did with in BASIC. This time I could use actual functions to replace repeating code. I had to replicate some of the array splicing, but there were ways to do that rather quickly in machine code. The final result looks pretty much the same as the test.
Run ML, ZX81 Screenshot, 2022 by Steven Reid
The only real difference is I added another cloud to the sky box. I also shifted a pixel in the shining sun. They are minor differences. A bigger change is that the animation is much smoother. The sky doesn’t stagger anymore.
This is where I stopped. I have ideas of building out different sky boxes and adding in some additional background effects. I thought those would be nice objectives for next month. Although, I should get the jump routine working first.
Although everything works, I’m debating if I will rework the display with a double buffer. Once I start adding more objects, it may be enough of a delay to cause some flickering. I have all those routines written, so it won’t be difficult to implement. For now, though, the demo works and I can focus on game play.