Zone of Fire tower defense game that's my first serious Unity project
Zone of Fire tower defense game that’s my first serious Unity project

Last year when I started doing game development I began with using the Cocos2dx game engine. Cocos2dx can be used for iOS and Android and uses the C++ language. I had done a little bit with Cocos2d (Cocos2dx’s Objective-C cousin) so I knew my way around a little. I wrote a couple of prototypes for games like an Asteroids-like anagram game where you shoot asteroids with letters on them to build a word, and a Space Junk game that’s a side-scroller where you have to steer your spacecraft clear of oncoming space junk.

I decided that I should be a little more ambitious with something that I wanted to release so I started working on a tower defense game. After a few weeks of work, I had bad guys navigating a path and towers shooting at them. It was quite a lot of work and everything was written using code, which was similar to what I used to do at Symantec. This project was taking a long time to get any progress so I decided to check out what kinds of games people were selling on Fliptopia and some other app broker sites. I noticed that most people were using the Unity engine so I decided to download it and see how it works.

A couple hours later I had already made a tower defense game that was further along than the one that I’d been working on for weeks. Seriously. Unity is a game engine and development environment that almost makes you forget that you have to write code to make a game. When you do need to write code, you can choose from C# or JavaScript. I know JavaScript pretty well, but decided to stick with C# because that’s what most people seem to use.

Whenever I do anything interesting, I have to show my 9 year old son. He was pretty excited about what I was able to do in such a short time. I was showing him some of the example projects that they had and we came up with the idea to make a first person game just to see what we could do. If you’ve ever used Unity, you probably know that you can make a first person game in a few minutes. First we made our character walk around some terrain. Next we changed our terrain to include some mountains. Then we added some buildings out of basic 3D shapes. Then we added the ability for the character to pick up 3D objects in the world and move them.

My son was pretty excited about this stuff and when he had his next opportunity with the computer, he made his own soccer game by himself. I was really impressed by that. He made a new game, added a soccer field texture he found on the internet, made goals out of multiple cubes, and created an arena around the field. He also made a soccer ball out of a sphere, complete with a soccer ball texture he found on the internet. His game was a first person view and his character had colliders detect when he ran into the ball which caused the ball to be pushed forward. He did this all without writing a single line of code. He asked if I could help detect if a goal was scored, so I did write a short script to detect when the ball’s position crossed the position of the goal line (and was between the posts).

In the meantime, I decided to get serious and write a newer better tower defense game. It probably only took me a few days to make a tower defense game that was actually playable. Despite that, I have been working on this game for at least 5 months now but most of the time spent is tweaking things, adding some complex behavior, or balancing game difficulty. I also spent a frustrating few weeks trying to figure out why the game was running at 3 frames per second on an original iPad Mini. I also spent a few weeks trying to get the game down from a whopping 1.2 GB in size to around 150 MB.

Stepping back a bit, Cocos2dx wasn’t terribly difficult to use to make iOS games because I’ve been a Mac developer for a long time and iOS and using Cocos2dx for iOS is basically the same as Mac development tools-wise. In order to make an Android game using Cocos2dx, it requires that you use the NDK or Native Development Kit that allows you to write C++ code on Android. Android apps are usually written in Java and in order to use C++ you need to use the NDK. To build for Android required some hoops to jump through and specialized knowledge and was a pain if I hadn’t done it in a week or two.

One of the great things I found about Unity is that it’s a cross-platform development tool that can create a game for pretty much any device and building for Android and iOS was just a matter of hitting Command-B to build it.

Stay tuned for updates about using Unity and starting my game…