I would like to know what other methods exist to implement a 2D wrapping world.

I know the simple modulo solution (ObjectPosition % MapSize) but that doesn't really fulfills my requirements. My issue with this easy solution that it only works on points and not on objects.

I was trying to clone / duplicate my objects and make them visible on both sides of the level that way but it doesn't really works out with box2d physics. So i am thinking if there is any other solution?

I would like to make my game world a truly looping cylindrical world, but i don't know what other methods exist to implement such a thing in 2D.

| improve this question | | | | |

Having a looping world can be summarised into two portions Rendering and gameplay.


First divide up your world into chunks. The chunks preferably should be of equal length for easy tiling. Hide the seams of these chunks with some clever level design. After which, rendering the level should be as simple as repeating the draw calls of the chunks with a specified offset that's the width of your chunks.


This one is a little tricky. Any game mechanics you implement should account for the fact that the world data is stored in the chunks above. That means any physics, AI, etc will need to know that they are reading from the chunk info and act accordingly. Especially AI. They will need to know that they are moving from one chunk to another and transfer their data accordingly to be stored.

| improve this answer | | | | |

You could for example create a clone for the object before it leaves the screen on the opposite side and delete the original as soon as it is "outside" the world.

The drawback is you have to ensure they behave the exact same way and what happens to the clone has to be applied to the original as well and vice versa.

I don't have any experience with the usual box2d implementation, but I am using the broadphase of box2d for a similiar spherical world.

Depending on how customizable box2d and your rendering pipeline is, you could store an offset for such objects and render them at their original position. If the origin together with the offset is on screen render it a second time with the offset. However I would assume that this is not easily extendable for the box2d Collision and/or Physics.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.