Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

As a summer project I decided it would be fun to make a Flash game. Right now I'm going for something like the look of Terraria. It's been a lot of fun, but today I've hit a snag. I need a way to generate my worlds. I've read up Perlin noise as a possibility, but I my attempts have given me sporadic looking results. What are some techniques used to generate these 2D tile-based worlds?

Ideally I would like to be able to generate mountains, plains, and caves.

share|improve this question
    
Could you post some of your existing results? I'm not sure I can answer your question, but (a) I'm curious and (b) it might be easier to visualize the problem you're having/what needs to be fixed or improved if we can see where you're at now. Thanks! –  Mitch Lindgren Jun 27 '11 at 23:17
    
What do you mean by "sporadic"? –  Byte56 Jun 28 '11 at 0:13
    
As Mitch and Byte56 say please expand your question, Perlin Noise is one of the common solutions, as is the related Brownian motion. For example Minecraft uses Perlin Noise en.wikipedia.org/wiki/Perlin_noise but ofcourse you have to do something with the random noise you get to make it look cool. –  Roy T. Jun 28 '11 at 10:39
    
Sporadic : Exhibiting random behavior; patternless. You'll need to smoothe the perlin noise out first, and think about what makes a terrain. Randomness is good, but if you want to generate a fun play area, you need specific rules as to what a fun play area is first. –  Jonathan Connell Jun 28 '11 at 14:39
1  
Check out gamedev.stackexchange.com/questions/4628/… Most of what you want is fiddling with the output. –  The Communist Duck Jun 28 '11 at 14:40

1 Answer 1

up vote 5 down vote accepted

It sounds like you're looking to generate a "side view" of the generated terrain.

There are plenty of terrain generation algorithms discussed on the web. You could probably adapt many of them by cutting out all but one dimension from the calculations. This would give you information about the primary surface/underground boundary. If you want to be more directed in your search, you probably want to look for "1D" terrain generation or "Worms-style" terrain generation. You'll get results like this thread on procedural terrain (including caves), and this interesting web demo.

Perlin noise alone would work well for the areas where you want to generate plains, since it's very smooth. It doesn't work so well for mountains and craggy areas with sharp discontinuities -- you'd want to combine it with something else for that. Consider the first portion of this page on fractal terrain, or applying random cuts and displacements to the terrain.

Caves can be done by randomly punching holes in your terrain as a simple first pass, but you can also look for information on how rooms in Rogue-like games are generated and apply that. You might also consider looking into cellular automata.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.