Before taking on a big project, it is usually a good idea to try out a small manageable project. This has been my approach to learning Unity, a game development platform. Several months ago, I choose two test projects to port from old 8-bit Atari and Commodore BASIC to Unity and C#. The first is this reverse sorting game. After seeing the Unity Asset Store, I may skip the second test project Litterbug and jump right into building an open world or adventure game. I’ve been really impressed with the quality and quantity of resources that Unity provides its users.
NOTE: I wrote this follow-up post many months ago. I originally planned on rebuilding it with animation and sound but moved on to some PHP projects.
This game was originally written for BASIC by Peter Sessions, published and edited by David H. Ahl of Creative Computing. This program is the from the time period before disks or CDs were included with the magazines and books, where the published version of BASIC might have subtle differences from the one you’re using. The original BASIC game is referenced mainly for overall rules and gameplay.
During my research, I discovered an Atari historian and publisher named Kevin Savetz has assembled an incredible archive of Atari computer books, magazines, podcasts and other materials relating to the Atari home computer systems. He also has a scanned copy of The Best Of Creative Computing Volume 1 from 1970, which includes a copy of Reverse. This scan is complete with an explanation, BASIC source code and sample run. The copy I have is from BASIC Computer Games, which is full of robots.
This is my first non-tutorial Unity project, built from scratch, start to finish. I don’t have much experience building games, however, I am an experienced web developer. My college education was heavily focused on C#, so I felt comfortable with the code right away. While I would normally opt for open source tools, I already had installed Microsoft Visual Studio to build a small system tray utility and saw no reason not to use it. It’s a pretty good development environment.
Below is a screen capture of the final game.
Just about every tutorial I’ve seen involves creating folders for Scenes, Scripts and Prefabs. It seems simplest to just create these right away and honour that good practice.
I originally expected that I would set the position of each of the nine objects relative to one another using a few calculations. I instead opted to use the HorizontalLayoutManager to easily and evenly space out a group of items in a Panel, which is where I added the HorizontalLayoutManager component. I then added a new square button with large single-digit text.
That’s about as simple as I could make the layout. At no point do I attempt to animate the objects in my layout manager. The effect is simple but immediate.
One of the things I really enjoy about learning to develop with Unity is that there are many tutorials, asset packs and forum posts to help a n00b along. One of these tutorials is a helpful hour-long video about creating a main menu with several submenus.
The original game scoring was based on the number of turns, with the fewest turns winning. This was a good starting point for scoring but I wanted to add a sense of urgency to the gameplay.
One of the problems with programming for older microcomputers was that there wasn’t a persistent system clock. Game speed was unreliable. There was usually a way of checking the number of processor cycles, but this would vary a lot between different models of computer. In those days, simply exchanging files between operating systems was an ordeal.
After a bit of experimentation, I decided to start with a bonus score and count down. The countdown starts at a certain level, and decreases by a value set in the controller. With each move, the decrease is accelerated. With each round, the starting time is lower but the bonus is higher, increasing both the challenge and reward.
To keep things simple, I created a panel and placed three text boxes in it, naming each. The first is for the bonus, reset on each round. The second is the for time that counts down each round. The third is for the total player score.
I found as a player that there wasn’t enough feedback between rounds and games. I decided to go with a simple approach and use a translucent overlay with a modal dialog that responds to a single click or press. I added the dialogs for the confirmation as a panel with several text boxes in it.
There are a few incomplete elements of this project. For one, there appears to be a sorting bug that sometimes presents itself.
The is also an incomplete bonus multiplier feature. The concept has potential but will take a fair bit of work to get it right. The multiplier is meant to provide more points for faster gameplay, along with multipliers.
The game could also use some basic instructions and improved messaging.
The project is hosted on BitBucket as an open source project. I have added a few typical templates in case anyone decides they want to work on this. In the end, I consider this an interesting learning exercise. Feel free to take a look.Source Code