Now in Sandoria there will be INFINITE WORLD!* Just recently, in a separate project, I tried to create an endless procedural generation of the world, which I succeeded in and now I was able to transfer this entire system to Sandoria! I had to make a lot of improvements and rework a bunch of scripts, but thanks to such a system everything began to work even more stable and much faster! Now the world is generated in the course of the player's movement using Perlin noise, using a special number (seed) to generate the terrain in certain coordinates.
How many 2D sandboxes do you remember with an endless world? 😄 Let me remind you that even the popular "Terraria" has a limited world!
Save and load the game.
Now only those chunks that were subject to change are saved to the folder, and chunks in which no changes have occurred are simply generated in a new way on the basis of (seed), i.e. this generation chunk will always be the same. I also added compression of saved files, due to which the files of the world began to weigh 32 times less!
Difficulties.
With this method of generating the world, not one grid is used, but several for each chunk. For this, I wrote special scripts that first find out in which chunk this coordinate is located, then return the block id relative to the current chunk. Thus, a lot of "invisible" errors were corrected that adversely affected the game process. After I made my own scripts for changing blocks, functions such as ds_grid_set_disk or ds_grid_value_disk_exists simply lost their proper functionality, because if you run this function on the edge of one chunk, it will not affect the next chunk, since these are two different grids.
Lighting.
Lighting of the visible blocks partially worked on one of the functions written above, but by rewriting the code a little, I realized that they could not be used there, so the lighting became even better, the only thing that needs to be slightly optimized.
Terrain generation and biomes.
In the video you can see that everything is generated by a solid oak forest, because you need to add a new biome system, where each individual chunk will already have its own biome(Already added). There were difficulties with the generation of caves and other structures, also because of the functions described above (I think I will soon find a solution to this problem).
🎬 Well, after watching the video, you can see how quickly the world is created, saved and loaded, and how the lighting is working at the moment.
* The world will not be entirely infinite. The fact is that when reaching the coordinates 4,294,967,295 or in blocks 134,217,727, in each side of the world, the computer number "Unsigned 32-bit integer" and "Signed 32-bit integer" is exceeded and something strange will begin to occur, approximately as and in Minecraft, "distant lands". I even figured out how to theoretically get around this, but I don’t think that it would take someone to travel so far, especially the height of the world, I remind you, is 2048 blocks! But if I suddenly figure out how to get around this limitation, the world will be about 134,217,727 times larger!
0 comments