I have a 2D world of 50*50meters and a viewport of 15*10meters.

Current situation:

    player.x = 0;
    player.x = World.WORLD_WIDTH;
    player.y = 0;
    player.y = World.WORLD_HEIGHT;

So when the player will be placed on the other side of the world when he reaches the border. The camera is always oriented on the player which results in an ugly "jump" when the player is replaced on the other side.

How can i optimize my render-class to flewless render my world.


The player is at location {0,0}. on the right the world should be rendered normal {0,0} - {7.5,0}. And on the left i want to show the other end of the world {-7.5,0} - {0,0}. Same for the Y axis.

I am shure this is a common questen and asked several times here, but i have not found anything with the searchterms "infinite world" or "repeating world".

any advices?

  • 1
    \$\begingroup\$ The term you're looking for is "wrap around". As for your actual problem, if we are supposed to help you with your renderer, why don't you show us the code for it? \$\endgroup\$
    – Hackworth
    May 10 '12 at 19:51
  • 3
    \$\begingroup\$ Also called a Doughnut World or Torus World. \$\endgroup\$ May 10 '12 at 20:22
  • \$\begingroup\$ By the way, and I'm obviously guessing here, you might want to take a look at the "player.x > World.WORLD_WIDTH" and "player.y > World.WORLD_HEIGHT" statements. It looks like the player can move 1 length unit outside of the world, since the largest player.x and player.y should be "WORLD_WIDTH - 1" and "WORLD_HEIGHT - 1", respectively. As you obviously know, coordinates are zero-based, so the largest index in an array is always 1 smaller than the length of that array. Using ">=" in both cases might be correct instead. \$\endgroup\$
    – Hackworth
    May 11 '12 at 8:48

These links might help:




You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .