First of all, introduction
In August 2015, while browsing through GitHub, I stumbled upon an open source project called Bacon2D. It is basically a framework created "to ease 2D game development, providing ready-to-use QML elements representing basic game entities needed by most games". The framework has only 2 dependencies: the Qt framework and the Box2D QML plugin, which is also available on GitHub. Since it is based on Qt, the framework is also cross-platform (although I haven't tested that theory yet ;)).The problem
After using Bacon2D for some days, I discovered a few drawbacks, the most annoying of which was the level building. If you wanted to build a 2D platformer (like Mario or Sonic), you would spend a whole lot of time building the level. You would have to manually position each platform and each object. At first, I was using relative positions by getting the X and Y coordinates of nearby platforms to position new platforms but it was too much work. Also, it was not a scalable or modular way of writing code. In other words, if I had to create a new level, I would have to go through the stress all over again.After googling on the issue, I discovered that the creators of Bacon2D actually have already started working on a solution to this, but stopped because they wanted to release a stable version of the framework first. So, after digging through GitHub, I found their code.
I took the code and wrote a few extra classes. These classes constitute the extension.
The solution
The solution I conceived after googling online was to create a level loader. The coder would create the level using a different application, generate a file, and this file would be used by the game to build the level. Easy breezy! Well kinda.I discovered an application commonly used to build levels called Tiled. It is an open source tile map editor and luckily for me, it was developed in Qt. So after seeing this, the plan was lucid:
1. Use Tiled to build the level.
2. Generate a TMX file for the level.
3. Get Bacon2D to understand the TMX file and build the level.
4. Make wonderful games!
The implementation
First, I downloaded the Tiled source code on GitHub. I found a way to compile it together with Bacon2D. After that was done, Bacon2D had the "ability" to understand TMX files. I could use the information from the TMX file to position objects and define the fixtures that would be used with the objects. I could also load background information from the TMX file. The code can be viewed here.
The result
I am currently using this extended version of Bacon2D to make a 2D platformer. My efficiency has improved by 1000%. Building levels is so easy compared to before, and I still get to use the Bacon2D framework so I think I can call this a win-win. See the screenshots below.
The first level:
The main menu screen:
The first level with a hint requested:
Don't let the ice blocks hit you:
How the heck did I get in this situation again:
The Tiled interface (the tile map editor where I do my level editing and building):
Right now I want to develop the game to a certain extent and release the code on GitHub as an open source game. I also am going to try to write full documentation on the extension so they may consider putting it in future versions of Bacon2D. (Wish me luck on that.)
And never forget:
“Imagination is more important than knowledge. For knowledge is limited to all we now know and understand, while imagination embraces the entire world, and all there ever will be to know and understand.”
I'm out!





