Box2D

An Introduction To Box2D

Posted by Amit
Comments: 2

1 Star2 Stars3 Stars4 Stars5 Stars
Loading ... Loading ...

The human brain works in amazing ways during class hours. Sparks of imagination fly as desperate measures are taken just to take your mind off a boring Maths or Software Engineering class (I find these the most boring. But the list is quite large :P ). So one fine sleepy afternoon hour, we decided to make a game and make an iPhone app out of it. Yeah we get these bizarre ideas every now and then. But then, making a game is interesting right? I mean, the pleasure you get when watching others play your game is something out of this world. How do I know? Good question. You got me :P

And so, over the next few days, we went to the lab and Google searched a bit on the topic. “Tutorial on how to make an HTML5 game” was one the first queries. We stumbled upon a great article by Net.tutsplus. Here’s the link:

http://net.tutsplus.com/tutorials/html-css-techniques/build-your-first-game-with-html5/

It explained in detail about how to make a game using JavaScript and the Canvas element in HTML5. The post opened with this:

What is Box2D?

Box2D is an open source and popular engine that simulates 2D physics for making games and applications. Primarily written in C++, it has been converted to numerous languages by community contributors.

Okayy.. so why do we need Box2D? You see, it’s very difficult to do the calculations needed to detect object collisions, and other scary Physics concepts if you have to develop a game from scratch. Box2D does all of these for us, and does it really well.

So what exactly is a Physics engine and what does it do?

A physics engine simulates the physics of objects to give them believable real-life movement.

And so, a guy called Erin Catto developed Box2D. Box2D is written completely in C++. Yeepp C++.

But it has been ported to many languages namely Java, JavaScript, Actionscript (Adobe Flash), C# etc.

So what’s so great about Box2D?

Ok you might be wondering – WTF is so great about Box2D? I have 2 words for you:

Angry Birds

This amazing game was built using the Box2D Physics Engine

Not just Angry birds. You must’ve seen Google Gravity right? That awesome place where you’ve seen the “fall” of Google ;)

Google gravity uses Box2D too

Still not impressed?

The stuff Box2D can do is really mind blowing. I’m not exaggerating, I swear!

Check this link out for some great demos.

http://gwtbox2d.appspot.com/

Conclusion

You can check out that net.tutsplus link I gave earlier to experiment with Box2D yourself. What? lazy to scroll? Okay:
http://net.tutsplus.com/tutorials/html-css-techniques/build-your-first-game-with-html5/

It shows you how to create a simple game using the Javascript port of Box2D. But I wasn’t satisfied. The Javascript port is not really updated. To play around with the actual C++ version of Box2D, stay tuned.. :)

  • Subash Gireesan

    Good one amit! Nice pass time!

  • Anonymous

    Thanks man :)
    So I do have readers ah? :D