In this article I want to share with you my practical experience in developing games for iOS based on open-source components. We will go through the technical decisions that were made during the development of the game.
Specification
The first thing I sat down to do the specification for the game. I decided that I would not write a single line of code until the specification was ready. Of course, during the development, it changed, but not significantly. The specification really helped not to deviate from the original idea. According to the specifications, I recommend reading Joel Spolsky's articles: http://www.joelonsoftware.com/articles/fog0000000036.html
Brief description of the game
One of the ideas of the game was to create a diverse gameplay. The main gameplay is RTS: ')
But in bonuses the user will have to shoot in the arcade style and even take part in one-on-one duels:
For each stage, the user receives a new unit or new ability. The first stages are training, but then the user needs to build his strategy to complete the level.
Graphics engine
Initially, it was decided to write a game in C ++, since a number of blanks were already prepared and did not want to waste time learning a new language. And also did not want to switch from Visual Studio to XCode. As an engine, I considered two options: Ogre3D and Irrlicht. Both engines are very good. The API of each engine is clear and it’s easy to figure out the main features. Irrlicht is smaller, but the OGL-ES branch is not official yet. But Ogre3D has an official branch. Still, the choice fell on Irrlicht, because the speed tests carried out gave a better result than Ogre3D. Irrlicht gave me the following functionality: • Rendering with OGL-ES. • Loading models from files (I used DirectX format) • Billboards • Animated models Irrlicht has its own XML parser, but I do not recommend using it because it is not very functional. It is better to use rapidxml or pugixml Also, the Irrlicht architecture provides the ability to add extensions without changing the engine code.
Script engine
The first engine I reviewed was tiny-js. After a series of tests, it turned out that it is too slow and in no way suitable for a mobile game. Next, I began to look at LUA and AngelScript. The speed of both engines gave good results. AngelScript has a C-like syntax, as well as the ability to easily bind C ++, which played a major role in the choice of the script engine. An example of binding a new function is as follows:
The AI ​​architecture for my project, I chose the "behavior tree". This architecture allows you to create complex systems of behavior and not to worry about all sorts of transitions from state to state. A simplified example of such an architecture: Adding a new behavior in this architecture is very simple: just add a new behavior to a specific tree node and that's it. For more information about the “behavior tree”, see the article “Introduction to Behavior Trees”.
Development
All code was written in Visual Studio. In Windows, I used the main Irrlicht branch, instead of taches there were mouse clicks. Once a week I compiled the current version on XCode and tested it on a device. The VLD library has greatly helped in fixing memory leaks. This library displays information on a memory leak with information about the code: