iPhone and box2d

March 10th, 2009

So, a lot of firsts today. This is my first blog post ever. I read programming blogs all the time, since they have loads of useful information, but have never made the attempt to write any. So, here goes.

I’ve been playing around with box2d on the iPhone using a port of the box2d library done by Hand Circus. Hand Circus created the iPhone mega-hit Rolando.

With somewhat limited experience with box2d and C/C++ I’ve been mainly tweaking settings and trying to combine the functionality of various box2d classes into a test app. I’ve found that box2d can be quite a processor hog on the iPhone: the difference in frame-rate I can achieve on the iPhone vs. the simulator is astounding. I’ve tweaked some of the settings, and have been able to make it somewhat acceptable with about 40 objects on screen; not great, but working.  I’ve recorded my little buoyancy test as you can see below. Forgive the amateur recording via laptop webcam, but you get the point.

My initial goal was to create an application that took on the physical properties of those blue and clear oil “wave machines”, for lack of a better term. You know, the ones at the junk stores in the mall; tilt them one way and the blue oil slides down to the other side like a miniature tsunami.

Obviously, I’m not quite there yet. I can get the gravity and norm vectors to rotate with the accelerometers, but to be just right, the norm should rotate slower than gravity, so that the floating circles slide down, rather than just bob up and down. Well, it’s a work in progress.