As of the start of this journal in April, 2009, my first Android game, Light Racer, had over 250,000 downloads and was on version 1.0.1. That game was developed in about 3 weeks time in my spare time and was released right when the G1 was made available. I had over a quarter of a million downloads of that first game, so why did I feel like spending months rewriting it and developing a 3D version of it? Well, I wasn't totally happy with the old version. It had really bad AI. I wrote that quickly just so I could have a computer to play against when testing but never implemented a better version. It was a little slow and choppy on some phones. It lacked depth and the way it was designed makes it hard to continue to add new parts to the game. It didn't have multiplayer support. It didn't look very nice. Basically, it wasn't a game that I could personally be proud of developing and I felt that there was so much potential for a great multiplayer 3D game, but I wanted to bring the 2D game up-to-date in the process, so I ended up doing both. Because of the months of development effort documented in this journal, Light Racer v2 and Light Racer 3D are both complete and are worlds better and more advanced than the first title. In the following pages, I give away many tricks and code samples of how to do almost you need to develop a good Android game.
This journal was written from day one of development. The course of development took about 5 months in total. All of the entries from this point on are written from the perspective of the day that the development was happening. If you want to learn how to develop games, I recommend reading every article in the journal. Many have code examples and there are lots of lessons to learn from them. I started the project not knowing as much about game development as I know now. I hope that this journal helps you on your way and that you are able to learn something useful from it. If you are a Light Racer fan and not a developer, I hope that you have fun seeing what happened to make the game completely come together.
Today Light Racer 3D is on the Android market and is one of the most advanced games available on this platform. This journal documents how many of the game's features were developed.
And here it begins... Day 0 (pre-planning)
The next article will contain more on this, but for now I'll say that the reason I care about Light Racer with regards to LR3D is because I plan to use much of the code from that game in the next. Through clever design, Light Racer 3D will mostly be the same code as Light Racer but with an OpenGL front-end and if I do things right, I'll have a game engine that will make it really fast for me to develop brand new games in the future.
Android is none too easy to develop OpenGL apps for. The API is just OpenGL ES, but the performance isn't very good and there aren't any tools for Maya or 3DS import/export.
What I intend to have is an identical feature set between LightRacer and LightRacer3D. Some people will prefer the old-school 2D LR, but I believe most will prefer the much flashier and first-person-perspective LR3D.
Here are my current problems:
1) The game is poorly designed. One activity and one 1,400 line class handles nearly everything.
2) There is no networking code, so no multiplayer.
3) The AI is too easy.
4) The game lacks depth.
5) The game looks cheap.
Here's what I plan to do about that:
1) Redesign everything.
First I will start by refactoring all of the existing code. I believe that by simply moving much of the specific game component code from the main class, I will be able to achieve an architecture that will let me plug in new components, such as input from the network or a new type of AI character. The individual blocks of code are good, but it's really an organizational problem right now. Some things will need to be totally redone, and MUCH responsibility will need to be delegated to GameObject classes. More on that later.
2) Write networked multiplayer code.
This can impact the app in several ways. For the most part, I can assume that if you're playing a TCP/IP game, that it's local and WiFi. This means that there won't be any problems with network congestion, latency or packet loss. This does not take into account how people potentially could be connecting their devices in the future. I shouldn't assume that it will always be WiFi. If I wanted to be really safe, I would need to account for packet loss, which means that the physics would need to use interpolation, which they currently don't. Beyond that, the design needs to allow for a network player to be assigned as the entity controlling a player, which it currently does not support.
3) Develop easy, medium and hard Artificial Intelligence.
The current AI can stay as "Easy." For medium and hard, I intent to test with an A* algorithm and then an evaluation function that will determine the AIs path by predicting what you, the player will do and plan on that. Curbing CPU usage will be difficult with that because that approach is a bit like chess AI. If it works out well, it will be certainly be hard, if not unbeatable. Medium AI will just be the A* algorithm with a simple heuristic and no prediction. There is yet another design problem with the AI, though. Currently the main class of the game simply has "updateAI" which runs for all players that aren't the one human. It should be fairly simple to do, but a new design will be needed which will allow for assigning a specific implementation of AI to a player.
4) Add more interesting game elements
One of the most common suggestions I get for LR is that it could use a little more depth. What exactly does that mean? How do I make it more fun? I don't want to pollute the game with objects that will take away from it's core gameplay, but I agree that it could use something that makes it a bit more riveting. Perhaps a non-player character (NPC) that flies around on occasion, smashing the walls down? Maybe a beam down the center which only allows for occasional pass? Perhaps a boost feature which allows a player to speed up? All of these things could be fun. I am considering all of them and once I get the new design down, I'll be able to play with a few of these things to see which are the most fun and which ones make you want to play the game more.
5) Tweak the graphics, add more animation capability and hire a professional designer
When I wrote the game, I never intended for it to be anything more than a test application. All I wanted to do was learn the Android API. Now I want to have a really great game, which will be Light Racer 3D. I can do certain tweaks to the 2D version that will make it look a little better but ultimately I'm going to need the help of a professional graphic designer. Thank you but no portfolios, please. I already have someone that I trust and have a good relationship with. The other thing that is limited in the current design is the ability to add more animations without using up too many more CPU cycles. This will be covered in the Game Architecture article.