Creating open world (with chunks)

First of all, I’m not a native speaker. I may mix up some words, so if something isn’t clear, pls aks ^^’

SHORT:
Need informative webpages about world generation with chunks?
Ideas on how to approach such world gen. in Defold?

LONG:
So, I started learning Defold in January and was often finding solutions to my Problems on the forum, but now I’m kind of lost how to approach world generation in my small open world suvival game (top down, 2D).

I already read and tried to analyze britzl’s example (from GitHub) about infinite world generation. If I’m not wrong the character is nor really moving, but the environment/ground is creating the illusion of the player moving (if I’m wrong could you please explain to me how exatcly the example is working?).

I succeed in creating a map (100x100). I used fractal noise for creating the environment and spawning my character. Said character can move around, but reaches the end of the map quite fast and I can not expand it further because I’m getting an error (because i cant expand it further than the bounds of the tilemap-file)

So now I’m quite overwhelmed… How do I approach the world gen with chunks? Do I need to combine both approaches? I tried to watch some tutorials even for Unity hoping I can adapt something into defold, without success.

You can create multiple tilemaps which you move to represent chunks. Assign them ids related to their relatively x,y index so the inital map might be 0,0, the chunk to the right 1,0, and the chunk to the left -1,0.

Then you extend the fractal noise into those chunks, and delete chunks as they are too far away. You can save world state into chunk partitions too. So if an object is in a specific chunk its x,y is saved relative to that chunk instead of the actual computed world position.

4 Likes

Thank you very much for your input. In the beginning i struggled pretty much, but I was able to adapt the code form britzl’s example to work with chunks instead of single tiles and generate the chunks correctly.

I’m going to clean the code up in the upcomming days and comment it out a bit, so I can share it via GitHub ^^

[edit: spelling]

4 Likes

I surprisingly had enough time today afternoon to edit the code a bit and push it to github:

In the upcomming days I’m going to optimize it. I’m open to critisizm and input ^^

[edit: I am still kinda new to GitHub, so if I mess something up pls be patient. I’ll try my best to correct it :D]

8 Likes