I put the last project I blogged about (Raceground) on hiatus. Instead I’m now working on a smaller project 2D mobile game. The plan is to check how viable the mobile game market is for me.
I started prototyping with Unity and soon ran to performance and scalability issues using the build-in systems (Tilemap etc). To battle those I would need to build custom systems for those anyway, so I again decided to move to just plain C++. The game is procedural so luckily I don’t need a dedicated editor. This time I tried to focus on building a game instead of starting building a game framework (entity systems, filesystems, other abstractions etc..) before actually working on the game itself.
To reduce boilerplate as much as possible and to make refactoring fast and easy, I don’t use C++ headers for my code. I have one .cpp file that is compiled which includes all other .cpp dependencies I have. Much of the game code resides in a single .cpp file which is now around 5000 lines long. I have a build.bat that just uses the MSVC compiler and only use Visual Studio for debugging purposes.
In my code I don’t use classes at all. Just plain structs and functions. I do use templated structs and functions for arrays. I don’t use STL at the moment. Basically, I only use dynamic or fixed array as a container, so I wrote support that myself. I avoid abstraction as much as possible and only do it when it clearly improves code readability and understanding. I do use third-party libraries such as SDL for windowing and input, stb_image for image loading, stb_truetype and fontstash for ASCII text rendering and bgfx for graphics.
This way has worked well for me, keep iteration time low and motivation up. Results come up fast and I don’t spend time thinking code structuring, abstractions, system refactoring or should the new class to be named XYZManager. At the moment, time to compile and run the game is much lower than script reload and play in current Unity!