Carving out the world
World generation is pretty important in a game like Spoxel. Since the entire world is generated from scratch it needs to be not only engaging but also interesting to look at. Many moons ago, when Spoxel was but a young game I had been using perlin noise to generate the world. That worked to a point, but I could never get caves to work exactly right. Also, I wasn’t sure how to make the work with rounding out the edges in a cave system using slopes. Well, I felt it was finally time to tackle that problem. This is a pretty old screenshot of Spoxel’s world generation. I used a combination of things to make that work. Most of the cave generation, however, was based on using a bunch of “stamps” I created and randomly placed. This worked okay to a point, but it didn’t make any sort of interesting pathways to explore and ended up playing kinda of bland.
So I began work on another algorithm. This time I used a combination of noise techniques to get interesting tunnels and caverns through the world. Also, instead of just using perlin noise to define the height at a given position, I actually used a perlin noise fractal pattern to deform the terrain. So now you can get interesting surface features like overhangs that weren’t really possible before. You can see some of those ridges in the image below.
So now the world is comprised of a number of different noise maps that are combined together in such a way that you can generate the world. Each biome tweeks those parameters so you can have jagged cliffs and flat plains all in the same world. I also wrote a post processor for each chunk that helps make the terrain more natural. Spoxel has a number of different blocks to work with that all can have different shapes applied to them such as wedges. So I wrote an algorithm which helped smooth out the surfaces in natural rock formations so you can have more interesting caves like in the screenshot below.