Caves and Features

This is another one of those ideas that feel obvious once you’ve thought of it.

I call it “Terrain Features”. Basically, it’s pseudorandom 16x16x16 terrain features that each have their own class and get plotted out based on some predefined criteria.

The trees in the current infdev version used a prototype version of this scheme. I cleaned up the code, extracted some simple APIs and ended up with an easy to maintain and expand upon structure. So I added a “CaveFeature” class that could get generated under ground, made the level generator spam it, and ended up with this:

image

Yep, that’s hugely complex infinite caves.

Each individual tunnel is restricted to just 16 blocks, but they overlap and intertwine, causing some mighty confusing structures. It’s not perfect yet, though.

Other features could be things like boulders, cacti, monster huts, small ruins, small lakes and lava pools, waterfalls (possibly? I hope so!), treasure chambers, or whatever else that fits within 16x16 blocks. And since they’re programmed, pseudo random, and aware of the blocks near the area they get injected into, they can have a lot of variety in their individual shapes. For example. making vines that climb walls would be really easy.

I’m also sketching on an idea for “huge features” (of which the pyramids are a quick prototype test) for things like towns and random dungeons. The problem is having some way of generating the huge features one 16*16 chunk at a time.

I expect to update infdev with saving, caves and tile ticking on Tuesday. As usual, I’ll probably miss that date by a day or two. ;)

posted 14 years ago