Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In my game I generate chunks when the player moves. The chunks are all generated on the fly, but currently I just created a simple flat 8X8 floor. What happens is that when he moves to a new chunk the chunk in the direction of the player gets generated and its neighboring chunks.

This is not efficient because the generator does not fill the entire screen. I did try to use recursion but its not as fast as I would like it to be.

My question is what would be an efficient way of doing so? How does minecraft do so? When I say this I mean just the way it PICKS which chunks to generate and in what order. Not how they generate or how they are saved in regions, just the order/way it generates them.

I just want to know what is a good way to load chunks around the player.

share|improve this question
Are you looking for only how to load chunks efficiently around the player, or are you looking for a way to load chunks so that the entire screen is filled? – fnord Sep 5 '12 at 17:46
Both load chunks efficiently and to fill the screen. – Trixmix Sep 5 '12 at 17:57
up vote 4 down vote accepted

If I understand you correctly...

Could you not just load the chunks in a spiral around the player? Each time you check for the next chunk to load you could start whole spiral process again (or come up with a better way to find 'missing' chunks) as this will loads the correct chunks whilst the player moves.

share|improve this answer
I will try it. Thanks. – Trixmix Sep 5 '12 at 18:14
What should be my ending condition for my loop? When the chunk xy is outside of the screen? – Trixmix Sep 6 '12 at 3:29
Distance from player? Far enough away so it looks right – Joe Sep 6 '12 at 9:51

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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