November’s Program: SNUNCH ML


Avoid the ghost and exploding pills in my PAC-MAN inspired ZX81 game.

[SNUNCH ML, 1983/2013]For November, I’m looking both forwards and backwards. Although I wrote SNUNCH in 1983, I added a corrected version to my first ZX81 web page in the ’90s. SNUNCH was my early attempt at writing a PAC-MAN like game. Note that I said like, not clone. My goal was to be inspired, not to copy. Sadly, it isn’t very good, even after I fixed some of its logic flaws. Despite its flaws, I still believed it had potential and I set about updating it using MCODER II. It is this improved SNUNCH ML version that I offer as November’s program of the month.

Back in 1983, I was very proud of this wreck of a program. Graphics wise, it isn’t bad. It has most of the elements found in a PAC-MAN game. There is a simple maze, a ghost, pills and a roundish character I called Snunch. The ghost is pretty easy to avoid, so I added two more elements to increase the challenge. The first is a timer. Dawdle too long and it’s game over for you. The second is the use of exploding pills. It was those pills exploding and reforming that I thought really made the program. Unfortunately, they also make the game almost impossible to play. The speed at which they explode makes them difficult to get without dying. Oh, and you need to get all four to clear the board or die from that timer. If you were fortunate to get one, however, there was a nice bug to make it a bit easier. More on that in a bit.

The other big problem, which isn’t too surprising, is that the program is a little too ambitious for the ZX81’s speed. It is trying to manage six graphical elements, all of which are moving or changing, using BASIC. Struggling to speed it up, I did the only thing I knew how back then. I added FAST, and as a result, I ruined the only good part of the program. Instead of nice, if slow, flowing graphics you get a flickering screen with little else to redeem it. Add the unfair game play of those exploding pills and you quickly understand why SNUNCH didn’t make it back on my site. Until now, that is.

While trying to decide what to do for this month’s program, I decided to go back and look at some of those programs from my first ZX81 site. I mean, wouldn’t it be nice to feature some of those programs that I hadn’t gotten around to showcasing again. That, and I was being lazy and didn’t want to enter a new program in. I had a number to choose from, but SNUNCH caught my interest. Remembering the performance issues, I thought that compiling it using MCODER II might turn it into a real gem. SNUNCH was a gem in the rough, so to speak, and maybe adding a little speed would help. With that thought, I dug in.

A couple of days later, I wished I’d just typed in one of those other program listings. SNUNCH wasn’t as easy to convert as I hoped. The maze logic was difficult to unwind into the simpler syntax required by MCODER. Some of those clever Boolean logic statements I’ve espoused on so much in the past frustrated me to no end. I didn’t just use them when moving your character, but I also used them to move the ghost and display the pills. I also used string arrays and string slices to print the graphical elements and their animations. Because MCODER doesn’t support string slices I had to drop those elements. As I dug further into the conversion, I also found all sorts of bugs and other oddities that needed to be corrected. The effort was worth it. SNUNCH was now playable, if still a bit rough.

Did I mention that SNUNCH would only display the reformed pills as you ate them? No? Well, the original program logic was so bad that it if you somehow sneaked past the exploding pill, you could basically sit there to clear the board. SNUNCH used a single variable that it incremented each time it found you in a pill’s position. You were supposed to eat the pills in a specific order, with each eaten pill remaining exploded and still capable of killing you. Even worse, remember that timer I told you about? It is a simple FOR loop that had to run out before you knew if you managed to gobble up enough pills. Even if you did eat all the pills, you had to sit there and wait to keep playing. I knew I had to fix these flaws before I could publish SNUNCH as a real game.

Firstly I added a numeric array that saved the state of each pill. As you eat a pill, it will go away and not count again. I decided not to leave the pills exploded as that wasn’t fair. Plus clearing the pills worked better visually. Interestingly, it also made the program play more like PAC-MAN.

Secondly I fixed the timer. I added an exit to the loop so that if you ate all the pills it would clear the board immediately. The timer in both version gets shorter the further you progress, but in the original game the timer would get too short making the game unplayable in its current state. To fix that, I played it several times to figure out how much time you needed to clear the board and then made sure the timer didn’t go below that number. To add tension as well as to make the timer more overt, I added the counter to the screen. This ended up being the only visual difference between the two versions.

Lastly I corrected the unfair game play. Being a much faster game now, the exploding pills were even more frustrating. I added another variable to manage the explosion time. It starts out pretty slow allowing you to easily dodge the explosions and clear the board. Each level takes some of that time off the explosion, adding to the difficulty but it tops out quickly while still being playable.

Oh, as a bonus I decided to add a little graphic routine the first time the game loads. It is all BASIC and simply displays the ghost and Snunch running across the screen. The original game didn’t display the program’s name until after you died. I thought that odd and added a title display to correct that.

SNUCNH ML is the game I should have written. Compiling it into machine language definitely improves many of its flaws. The changes I made have turned into a real game that improves on the original without changing it. One more thing, the program has a high score variable. If you play it, I’d be curious how far you get. I put in the highest score I hit during testing, but I know you can go higher. I beat my own high score when validating the timer routine and grabbing the screen shot. Let me know if you beat it!

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. A compressed copy of the original SNUNCH is also available. You’ll need to save the .p version of the program to your device to allow Zed Ex (Beta) to run it.



Comments on this article:

No comments so far.

Write a comment:

Type The Letters You See.
[captcha image][captcha image][captcha image][captcha image][captcha image][captcha image]
not case sensitive