# How do I generate random mountains in a sidescroller?

So I'm trying to make a simplified Terraria style world using Perlin noise. I got that working and the terrain is randomized. However the terrain always looks like like a weird cosines curve. Hills and bottoms with different heights repeating. The effect I want to achieve is something similar to this:

Where the terrain is mostly flat looking and sometimes a large mountain will appear.

Is there an algorithm or "noise" that could achieve this effect or what other things do I need to do?

• You could try layering your noise, or change the way you use your noise to determine height, you could, for example, generate a top-down heightmap and for each pixel remove it if the height is lower than the distance from the pixel to the bottom of the image. – Niels Mar 7 '16 at 14:00
• You've posted what you want but not what you have, which might help tailor the solutions to the specific issue you've got. – user1430 Mar 8 '16 at 19:19

You want to mix different wave lengths with different levels of intensity.

E.G. Have one long wave, that has a high intensity, and a short wave with low intensity.

Now add the two(or more) waves together. Black line being long waves and high intensity.

Red line being short waves with low intensity.

Green being the final result.

float getHeight(float x) {
float longWave = getNoise(x / 100) * 20;
float shortWave = getNoise(x);

return longWave + shortWave;
}


Eventually add more waves, maybe using different noise algorithms. Play around with the values. To get more interesting results you could also try to multiply different wave lengths, make them exponential etc...

• I would like to point out as well that the waves must be built so that their sum is not periodic as well. One way to accomplish this is to not have their periods be rational multiples of each other. – user64742 Apr 1 '17 at 21:37