2D terrain generation - with caves and overhangs

well, at last i’m having a little free time and with a friend of mine, we are begining a new game, a pure java2d worms clone.

I have used a midpoint displacement algorithm to generate the terrain, with some good results, but as this algorithm outputs only one height for each width point, it won’t generate caves nor overhangs, and they are a must in any worms clone :slight_smile: .

Are there other 2d terrain generation algorithm i can use? i have founds losts of papers about 3d terrain generation, but no one covering this topic.

thanks

not to sound stupid… but couldn’t you just generate two landscapes? one for the bottom, one for the top? shrug

that would be fine for a cave-like map, but i’m looking for something like these concave areas

OHHHH I get it. sorry :stuck_out_tongue:

no problem ;D

I don’t know nothing about algoritams for terrain creation… so here is an idea.
If you can, how about you additionally generate some round type random irregular shapes on map and then substract them from original terrain. That way you can get caves, wholes in terrain or whatever… only problem is doing substraction.

Semi-randomly placed metaballs could work well. I’ve been meaning to try that for quite some time now.

wow, thanks ;D i have just found a good tutorial on metaballs, i’ll give it a try tonight

I think the maps for worms were all created by hand. Obviously they had some elements that got used in chunks like those icecream cones.

well obviusly not since those ice-creams have horizontal pedestal that sticks out so they are computer generated.

Huh?

The pedestals are clearly part of the artwork for the placables.

There is no reason they could not have been dropped in by hand that I can see…

I’m pretty sure the game advertised with “with over 4 billion maps!”

So it must have had a seed-based mapgenerator.

“so they are computer generated.” … I mean maps are computer generated, not the artwork, my bad formint the sentence. If it were by hand nobody would put an ice-cream with pedestal touching ground with one pixel and the other 50 are above the terrain, in the air (like the most right ice-cream).

One way to do these things would be to define the boundary between ground and non-ground as a contour curve of some function f(x,y), where the values of f could be randomly generated according to - for example - a diamond-square algorithm. Of course this will treat the x and y axes equally, which might not be desirable when doing a sideways-viewed game. This method would require a grid, but one could interpolate to achieve smooth boundaries.

Of course lots of information is lost if you just use a contour. I’m sure there are more elegant ways to do this.

Worms map are random generated, each map is a set of two 2k files, one for the ground and other for the ubicates, and the image is way too large to be compressed into 2k ::slight_smile:

btw, the metaballs worked fine, here is a test

thanks a lot