I was wondering how to create infinite 2D platform terrain. I've read about perlin noise and I have an idea I'd like to illustrate below.

enter image description here

However, I have no idea how to achieve this. Are there any common practices in the game industry or any techniques you can share?

On a side note, I was wondering if it is possible to "influence" the perlin noise function in some way. For instance, say i'd like to make sure at some point that a large tunnel that goes down for _ many meters. Or, I'd like to make a mountain right here _.

Since I am very ignorant to this topic, I can only speak in theory, but I really appreciate any advice or direction. I am working in C# w/ XNA.

  • \$\begingroup\$ +1 excellent question, I would love to know the answer to this. Why not just generate randomly and "fix up" the edges so they connect seamlessly? \$\endgroup\$
    – ashes999
    Apr 30, 2012 at 1:04

1 Answer 1


Your basic idea and illustrations of it are good. You may wish to look at "Simplex Noise," it avoids some of the artifacts of Perlin's noise and runs a wee bit faster.

Noise is just one step to generating terrain. You can certainly modify the output for tunnels or mountains as a step after the noise; and that's how noise is most used, as one stage of a chain of composited output. You don't influence the noise generator, you just keep adding more stuff afterwards.

In your case, you'd make the baseline silhouette with noise like your picture shows. Then a tunnel marker is added where you want, that guides digging down into the ground. This would be a tube broken up with some fractal noise to make the edges look natural.

An example from planet building which I just recently did: Noise generates big blobs that become continent and ocean. Only on the continent area a different kind of noise (Ridge Fractal) is added to make mountains. Only in the ocean is yet another kind of noise (Billow) is subtracted to make deep sea fissures. Only in shallow ocean the bottom is flattened out to make continental shelves. And so on, more and more layers of different noise and fractals composited like an automated photoshop job.

http://pcg.wikidot.com/ is a good place to read more.

  • 1
    \$\begingroup\$ I'd love to see some screenshots of how your various noises worked out together. \$\endgroup\$
    – ashes999
    Apr 30, 2012 at 13:25
  • \$\begingroup\$ Hi Patrick, thanks for the great answer. The parts that I'm having the most trouble with are steps #3 and 5. Can you explain how people usually approach these? \$\endgroup\$
    – Kevin Wang
    Apr 30, 2012 at 14:00
  • \$\begingroup\$ A tunnel marker in my example is just a premade line segment list of what a tunnel is, used on your data to guide eating the tunnel out of your ground. The fractal part is just a small scale perturbation of the edges of your tunnel while it's being eaten/created. Another resource for caves and tunnels is to look at what Notch did with Minecraft, search for discussions on how he builds his random terrains. Yet another resource for noise is to check out a library called "libnoise," which is a small but useful framework for chaining and compositing noise. \$\endgroup\$ Apr 30, 2012 at 17:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .