събота, 26 юли 2014 г.

Starting as a game developer - part 1

I haven't posted anything to my blog for a long time, as I had a really tough time with my exams. However, everything turned out okay and I'll try to keep up with weekly posts.

I have been passionate about game development since I was a little kid. I was also passionate about playing games, but that's another topic. I really wanted to know how games work from the inside and be able to create my own game. And now that I have finished my 2nd year in university, I have more than 2 years industrial experience and a lot more experience messing around with code and small projects, I think I am ready to start creating my own simple game. I have decided to write a series of posts about it, as I plan to release everything I make about this game freely available and also follow the process of development. This may help me find my own mistakes or maybe someone can suggest a better way of doing something.

I. The idea

I first started with the idea. As a normal game developer I have loads of ideas, most of which are probably not able to be developed by a single person in his life span. Instead of making a RTS or a MMO game, I really wanted to start with something simple. A simple puzzle game came to my mind, that I used to play a long time ago somewhere on the internet. I started messing a little bit with the idea and to write some stuff down. The main part of the game is a table with 7x7 elements. Each element can be one of 4 colours: yellow, blue, green, red. The element in the middle of the table is empty and that's where the player starts. On every step, the player has to choose one of the colours and every element that is of the same colour and is visible from the start position(can be reached by moving on empty spaces) is destroyed. The goal of the game is to destroy a specific number of elements in a specified number of moves. Here is a picture that may help you understand the game:

II. The tech

After I had my idea clear in my head, it was time to choose a way of creating the game. What I wanted is to use C++ and make the game available on PC. Also I was thinking about deploying it to Android and iOS, once it is ready and I have time for that. So I started looking at various technologies that may help me with this.

The most flexible and powerful library to use is OpenGL. It is free, cross-platform and almost every other engine or library is built on top of it. However, this was not my choice. As it gives you the ability to do almost anything, it is a bit difficult to use and you have to write everything on your own. As I am a single person with limited free time, it would take me quite some time to create even the simple game I wanted.

Other libraries that I could use are SFML, Alegro, SDL, etc. They are built on top of OpenGL and simplify a lot of the things that you would want to do (for example just opening a window is a lot easier in SFML, than it is in OpenGL). I chose SFML to go into deeper research. I went through a few tutorials, and I can say that it is easy to use, provides you with the possibility of using the full power of OpenGL, while still simplifying a big part of it. I went through a few tutorials and I was ready to start creating my game. However, I wanted to make sure I was making the right decision, so I continued my research.

My third possibility was to use a game engine. I was a little bit sceptical about this, as I didn't want to just "drag and drop" my game and most of these engines provided limited flexibility. I first took a look at Unity. It is great if you want to target multiple platforms at once, as it does all the transformations for you. It has also a really great support, with constant updates, big community and loads of tutorials. However, there are two things that I didn't like about it: you have to use C# and the price for actually using the non-free version is a lot for a student like me.

So I looked at another engine: Unreal Engine 4. It suited everything I wanted: it uses C++ and you can deploy your game to multiple platforms. It is also cheaper than Unity: $20 per month. The best part is, that it is open-source and you can modify it as much as you like. Also you can keep your copy if you cancel your subscription. The support is good. It does not have a lot of tutorials, but it has a lot of example projects, which you can freely download and have a look around. The community is also really helpful. I bought my license and started messing around and trying to create something. If you want to use Blueprints, which are Unreal Engine's "drag and drop programming language", you can start creating your game without a lot of programming knowledge. But I wanted to use my experience and knowledge and use C++. Well... everything looked easy to do on first sight, however, I didn't felt like writing C++ code: there were problems with the Visual Studio auto-complete, as UE4 is quite big and my laptop was struggling with it (and I have quite powerful laptop), the documentation wasn't very complete for 2D game development and most of the tutorials were for 3D FPS games. And I understand this, as Unreal Engine was designed with FPS games in mind. With the newest version 4.3 (at the time I am writing this) there is a beta plugin called Paper2D, which might make it easier to create 2D games, but still I didn't feel like writing clear C++ code and having the whole power and freedom that the language provides. Also, I managed to break the engine quite a few times and mess up the whole project and had to start from the beginning. I tried contacting the staff and community for one of my bugs and they were really helpful.

After deciding not to use Unity and UE4, I was left with just using a library to help me with the simple stuff and re-invent the wheel with the more advanced stuff. However, I remembered of a framework: Microsoft's Marmalade. It provides a graphic library called IwGx, which is basically a simplified OpenGL library. It allows you to do anything and even to use Cocos2dx or similar libraries. You can then deploy your game to iOS, Android, Windows Mobile, Blackberry and Windows 8. It currently offers a free license and some paid ones, which are a bit expensive for a student, but I can use the free version to start developing the game.

I chose to use Marmalade and I hope I didn't make a mistake, but I'll stick to my decision. However, I'll separate the game logic from the rendering and input handling so that I can later change my mind about the technologies I am using.

III. The plan

Basically this is what my initial plan looks like (sorry for the crappy quality... my phone isn't hi-tech... and I had to remove the ads from the notes):

...and I am still following it. As I don't have experience creating games on my own, it was hard for me to make a more detailed plan. But from my experience working on other projects, I know that it is better to have somewhat of a plan, than not having one at all. I tried to separate the game logic as much as I can from the graphics and interaction logics, which would give me the opporrunity to make later changes to the graphical aspect of the game, without a lot of messing around. I then split the development into small tasks , which I could develop for a day or a week so that I can follow my progress. I was also sure that a lot more tasks will appear throughout the develppment, but I needed something like a start point.

I will dedicate the next posts to the development process and the problems that I face during it.

Part 2