In order to finally start iPhone development, I decided to start with something I would enjoy, required the least amount of Objective C fiddling, and had a graphics API I was familiar with, OpenGL.

Enter left, the bridge building game. The physics are beyond my capabilities, so I figured Box2D would be just what I wanted.
Turns out, you still need to have a brain, nuts.

When I first started, I used the Box2D bridge testbed as a starting point, where it creates bridge segments, connected by revolution joints.
This works fine if all you're doing is creating a single layer of bridge segments to go from one side to the next.
The problem comes when you try add support structures, as you cannot add 3 bodies to one joint, as seen below.



Mnem was kind enough to suggest swapping the roles, replacing the bodies with distance joints, and the joints with bodies to hold them together.
This works great, as you can use the distance or reaction force of the joint to snap the joint when the force is too great.
The problem with this, is that you can't collide with a joint, so any vehicle travelling over the bridge would just fall through the structure segments.



My latest thinking involves a mixture of distance and revolution joints, and bodies acting in different roles.
So for the main structure segments, that the vehicle will travel over, you have a pin(body), connected to a joint(revolution), which is in turn connected to a structure segment, and/or a support joint(distance).
This means that the bridge is still flexible, can still be supported, and can still break, without uneven tension across its structure.



( 425 views ) permalink print article