2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ 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? \$\endgroup\$ – fnord Sep 5 '12 at 17:46
  • \$\begingroup\$ Both load chunks efficiently and to fill the screen. \$\endgroup\$ – Trixmix Sep 5 '12 at 17:57
4
\$\begingroup\$

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.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ What should be my ending condition for my loop? When the chunk xy is outside of the screen? \$\endgroup\$ – Trixmix Sep 6 '12 at 3:29
  • 1
    \$\begingroup\$ Distance from player? Far enough away so it looks right \$\endgroup\$ – Joe Shanahan Sep 6 '12 at 9:51

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.