I've got a question; I'm creating a game which requires wrapping maps (that is, allowing maps to be virtually infinite by wrapping around itself); would this be possible in Box2D via any sort of weird hacks? The only way I can envision this working is by basically warping entities if they reach a boundary, but, that wouldn't let bodies collide if both of them are on a boundary. Any ideas?
-P
We're doing this by dividing the world up into (fairly large; about 2x2 screens) cells. Then you can instance a cell any place you want it, even multiple places. We keep about a 3x3 grid in memory, though we get a lot of slowdown mostly during shape terrain deconstruction, so you need to do all sorts of caching and deferred destruction.
I get the idea, but, keep in mind I'm talking about entities that persist across these screens (ever played Gauntlet? Yeah, that.). If you keep walking to the right you'll see the same enemy instances.
I imagine this kind of system would require cloned bodies across each side or something, although it wouldn't be perfect, and would have noticable issues if you were doing things directly on the boundary (or being pushed between two boundaries)..
-P
Cells can work for this as long as the corridor doesn't wrap too quickly. If you have, say, 2 screens before you wrap, make the cell size half a screen wide and keep 1 cell loaded on either side of the cell that the character is in.
When you unload a cell, record all the positions of the entities.
Just duplicate the object when it intersects the boundary. This will depend on your implementation of the object.
On a high level, the "Base" object will have two bodies. If it is intersecting the side of the screen, one body's position is relative to (0,0) and the other's position is relative to (width, 0). Apply all forces applied to body one to body two, and vice versa.