Every decent project starts with a dumb idea.

In my case, I was lying in bed and thinking aloud about how pointless are mobile games nowadays. Having recently discovered an android easter egg game about collecting cats, I realised that I actually find it rather entertaining. I can play this game, even though it’s not a game from a traditional point of view – it doesn’t have a win condition and you can’t lose. No points, no challenge, just choosing a bait and waiting for a new randomized cat picture to show up. Simple, fun, addictive.

These three keywords were already on my mind for quite a while, and I eventually condensed them to a simple concept. A clicker game. You click and get some silly stuff in return. You can stop. Or you can keep going, and there is no real reason not to. Different styles and settings came in mind, I even started prototyping a game about a soviet scientist working on nanomachines – they have a military application, they go out of control – a classic grey goo scenario. I might come back to it eventually, but for now I deemed it to be too complex. It had to simpler.

I kept talking and jokingly said that I can even make a game about pressing the “Close Doors” button of the elevator and people will still play the game. Usually ideas just root themselves in the back of my mind and start slowly developing there until they are somewhat worth thinking of. That’s why I didn’t think I’d come back to this idea a few days later. Maybe it was so simple it didn’t need much time to grow. I started working immediately.

Gameplay is simple. You click a button, the faster you click, the higher the amount of points you get for each click is. Multiplier increases over time if you’re fast enough and decreases if you slow down. Eventually there is a “next floor” transition so you can rest for a couple of seconds and get a recap of your performance. Any moment you want you can exit to menu, if you want to. Achievements like playtime and highscores unlock new “levels” with the same gameplay, but different looks and style. Add some jokes and hidden stuff and voila – it’s a good enough mobile time-killer application.

As any clicker game goes, this one didn’t need much in terms of coding. A button trigger script, global data for highscore and achievement storage, and a menu system. A prototype in Unity3D was done in a few hours, and then I decided that it’s too ugly and “a bad code example”. Keeping in mind it had to be deployed to Android, as well as PC, it was true.

The button trigger part is modular. One script handles the raycast, then another one on the button itself activates all the events that happen when the button is pressed. It can be triggered by anything, so the PC version can use either a mouse or a keyboard to control it, for example. I still can’t decide whether I put everything into one file or not, but I’m keeping different classes for different stuff. Nobody wants to have the code for animations mixed up with the scoring system. Best part is, I can easily swap out different scoring systems or add/remove different events.

As you can see from the diagram, I decided to connect everything using a single Data class. Implementing a singleton in Unity3D was easier than I expected, but it is not a fully lazy implementation and I could create more of them and break the system if I wanted. However, it was good enough for most purposes. After creating the GlobalData itself, I had to do something with it, otherwise it’d just be a brick of nothingness.

The main idea was to have several lists of different classes, each containing data about achievements, highscores, level parameters (e.g. max multiplier) e.c.t. Writing every constant in code seemed like a bad idea, so I decided to implement data files. At first I thought I could use a single file, it would’ve made things easier but significantly impacted runtime. I decided to go with different files for each type of information. Achievement data was in one, level data was in the other and so on, and so forth.

Unity3D uses serialization to save and load information. Basic process of loading is: find a file, create a stream of data from this file, decode it, put it into an appropriate variable, close the file. Saving is similar in concept. Now, usually if data is stored in a database with proper file formatting, like XML or Json, it is possible to use an external editor to modify different values. I didn’t want it to be possible for a player to tweak levels and unlock achievements through changing the game files, so I used binary serialization. Having different types of data, I couldn’t just create a single method to handle it all, so I had to use generics. Final solution looks clean and can be used for any type of data.

Having completed the save/load functions, I started working on the editor. Custom editor windows in Unity3D are a powerful tool, and I didn’t have much choice anyway, since all game data was encoded into a raw binary data stream. After having some problems with Unity doing nothing and a days worth of suffering with MonoDevelop’s built-in debugger, I finally got it to work. Just a simple window, like any other Unity Editor window, that allows me to manually type in and immediately serialize different values into different data files.

With all that done, the game was basically ready. Everything else – 3D models, sounds, menu UI – is the easy stuff… Except it isn’t. 3D modelling and wiring up everything together will take the majority of the time. But for now I have a working prototype, parts of which can be easily modified and replaced, and I have the next few weeks to do stuff in Blender, make a scene manager and try to learn how to deploy stuff to Android.



Next week’s update will be mostly about UI and creating a comfortable experience for the player.

