I don’t know if you are like me, but I loved the golden age of 2D side scrollers back in the day, and the more recent resurgence in them. Now, they are more creative, beautiful, story-driven, and powerfully resonate with gamers. It is very different from vague stories like the Castlevania franchise’s ‘Dracula bad, kill Dracula’.
Castlevania: Symphony of the Night was one of my favorite games of the 1990s, and I would love to be able to start to create my own 2D game. Okay, okay, I know it is a pretty tall order to want to just spit out a clone or spiritual successor to not only one of the most popular games of both 1997, but of all time.
But I believe I can get there. All I have to do is find the engine that best works for me. One where it includes the very basics of a 2D engine, naturally. I need to know the ins and outs of 2D collision detection, physics, and other aspects of 2D games if I were to go on with my project.
Do you find yourself in the same boat? Are you trying to put your own spin on games like Metroid, Braid, and Castlevania? I have good news—Box2D just may be the first step in achieving that goal.
If I wanted to start developing a very simple, bare-bones kind of game, one that deals with the foundations of such a game, I couldn’t find a more suitable engine than Box2D. First released in 2007 as Box2D Lite, what we now know of Box2D has had a most recent stable release in April of 2014.
What is the best way to sum up what Box2D is? Here, let the developers explain,
“Box2D is an open source C++ engine for simulating rigid bodies in 2D. Box2D is developed by Erin Catto and has the zlib license. While the zlib license does not require acknowledgment, we encourage you to give credit to Box2D in your product.”
I love to donate to determined developers so we can keep receiving a sweet product with constant updates. It’s the least you could do, guys! If you find yourself using Box2D and loving it, definitely drop these guys a few bucks.
Collision Detection and Misc.
A big issue that Box2D deals with and stresses is collision detection. Collision detection is especially emphasized in video games. Very generally, it is the issue of two game objects, (buildings, characters, etc.), colliding with one another.
Have you ever been playing a game and seeing two characters run into each other, morphing into some sort of grotesque monster? Well, never fear, it’s not your worst nightmare, it’s just that those two models encountered a bug and the collision detection was ‘off’.
Box2D engine has been included in some titles on the Nintendo DS, the Wii, and others, and offers cross-platform. This includes the potential to port to mobile phones especially. Imagine you develop a new, more modern version of the cellphone classic ‘Snake’. I can already hear the cartoonish cash registers going ‘KA-CHING’.
It also includes a crazy laundry list of necessities of a 2D engine:
- Contact callbacks: begin, end, pre-solve, post-solve
- Convex polygons and circles.
- Multiple shapes per body
- One-shot contact manifolds
- Dynamic tree broadphase
- Efficient pair management
- Fast broadphase AABB queries
- Collision groups and categories
That’s just having to do with collision detection alone. And that’s barely scratching the surface when it comes to the things included in the engine like physics, the system, and the testbed. But I digress.
What the user will be treated to upon booting up Box2D is a very retro style looking field. The objects included in the engine are very rudimentary; think ‘Asteroids’ and other games that were popular in the late 1970s and the 1980s.
So now we know more about Box2D and what it is all about. But how do we go about starting our project? Where do we go from here? It is great knowing the origins, but I can tell you want to get down in the nitty-gritty and start developing your own visions and projects. Well wait no further: we have 5 great tutorials and leads to get you feeling at home using Box2D and help you get started.
Tutorial #1: The Coding Train
I love this guy. He gives off a great dad/professor vibe. His friendly manner and great voice inflection are super easy to follow and will definitely help you with the intro to Box2D. He is very animated, and you can tell he cares a lot about his field, which is invaluable.
He goes over Box2D specifically in detail, he also has tons of videos having to do with coding. These videos start at the very beginning of one’s coding journey and move onto more advanced aspects of entering the code.
Definitely check out The Coding Train if you are interested in getting the most out of the Box2D engine as well as coding in general. This appeals to me greatly as I’m code-illiterate. To be honest guys, it all looks like that funky green text featured in The Matrix franchise. Just gibberish on the screen.
However, I can tell if I buckled down and watched this guy’s videos, I just might make my way to a better understanding of a more common understanding of coding.
I’m sure he’s able to be contacted if you have any questions about his theories, lessons, or tutorials. In fact, I might shoot him a line right now.
Tutorial #2: Sonic Physics Guide
This was a cool little tutorial on physics in a 2D space that I found when researching the communities of game developers. A user was unsure how to utilize physics properly and a fellow developer linked him to this page. It includes an exhaustive checklist on physics, not only having to do with our favorite, speedy hedgehog, but with basic game physics.
Again, the details are supreme, with in-depth physics and math are applied to help you better understand the nature of the 2D engine and more specifically mapping 2D characters in a 2D world.
Using an already existing 2D game and its assets are a great idea. All of the subjects are pre-existing, so all the developer has to do is look into the more specifics of the character model, (which again, is already there), and study how it is implemented in its own game, hopefully guiding you toward a more cohesive game experience with your own project.
Tutorial #3: The Official Box2D Manual
I love when developers have a clear, concise, and detail-oriented manual that is easily accessible from their site. Box2D engine is no exception, with the moderately long, (clocking in at about 68 pages), manual describing everything you need to know to get the engine started.
In the very beginning, they warn prospective users that Box2D probably should not be their first foray into coding. Now, I know if you are looking up game engines, you probably already know some C++ basics, so proceed.
A standout feature of the manual is the highly helpful glossary right at the beginning. They literally begin at the definition for ‘shape’ within the engine, (FYI, it’s a 2D geometrical object, in case you forgot), and move on to the more advanced topics. I have to say that their very first section is so helpful.
They basically give you a little geometry primer, (never fear, it isn’t 10th-grade math class!), and help you get a better gist of what the engine does and what you yourself will be doing within its confines. They go from the very first line of code you will type to the debugging process in your project.
Tutorial #4: Stackexchange ‘Game Development’
This cool little site is dedicated to people who are seeking out help with their projects, whether it be with the engine itself or game development theories in general. The main page contains questions asked by users and the subsequent answers that other gamers are nice enough to help with.
Not only does the site contain a helpful community, but also a community that asks the hard-hitting questions like ‘Why Did Howard Stark Use All the Vibranium They Had On A Prototype Shield?’. I would like to know too, but let’s stick to game design, guys! But seriously, why did he do that though?
An off-topic forum can also serve as a nice rest if your brain is fried from too much coding. Let this friendly community both help you out and help you unwind with some fun and entertaining conversations.
Tutorial #5: The Box2D Reddit
Probably my favorite resource for nearly anything I can think of is Reddit. The Reddit for cooking, the Reddit for gaming, the Reddit for DIY housework—it’s all there. And the Reddit specially made for Box2D is no exception. Although it’s a smaller community, (not like the insanely populated PC Gaming Reddit of millions), it’s a tight-knit one.
Something about game development really gets the creative juices flowing and it’s a beautiful thing to see people helping each other out of technological jams. If you have issues with the engine, chances are there’s a topic already posted about it, or you could posit the question yourself to the Box2D community and it will most likely be answered in a reasonable time.
The moderator actually just reactivated the subreddit after requesting to do so from Reddit. This means the community is still always developing, but it’s definitely getting there after a short time.
Generally, finding any community like forums online is a great asset for whatever needs or questions you may have regarding game engines, especially Box2D.
Pros and Cons
- Free! It uses the zlib license. It’s a free license much like the MIT license we have seen before in different engines. Usually, when an engine is free and they use one of those licenses, the most that the developer is required to do is just include the copyright of the license in their projects. Pretty sweet deal, huh? What do you have to lose in downloading it? Even if you absolutely hate it, just uninstall, silly!
- Versatile. The engine is so malleable it is almost obscene. It’s able to be ported to so many different programs like Java and the aforementioned mobile devices, even the ancient BlackBerry!
- Good documentation. The guides included with the engine, specifically, the one on the official site, are sublime. They are very detail-oriented and very comprehensive, allowing the reader no leeway for getting lost creatively. This is a welcome change from engines that make you rely on blog posts to learn the ins and outs.
- Possible difficulty curve: as the developers warn at the beginning of the manual, Box2D probably shouldn’t be the first experience that a developer has with coding or game development.
I think it is pretty clear that the Box2D engine is a unique little engine if you are interested in more in-depth concepts of coding like collision detection and other bits of 2D know-how.
If you are familiar with C++ and have a penchant for 2D games, more specifically something that teaches you more about the basics of game design, (i.e. physics, collision detection, etc.), this just might be the ticket for you.