Search code examples
mathtrigonometryterrain

2d Mountainy Terrain


Hi i am new on strackoverflow, could anyone help me with 2d Terrain trigonometry algorithm, how to achieve something like in screenshot?

enter image description here

this tutorial helps me a lot but still can't figure out how to create mountain terrain

My attempt evolved to this:

Vector (v0.x + t * length, center + amplitude * Mathf.Cos (angle * t));

thanks in advance


Solution

  • it looks like chain so:

    1. generate n random height points

      just the peaks covering your screen or map or whatever.

    2. compute chain between neighbors

      the chain length should be bigger then the distance between points. For the math see:

      equation

      the equation image was taken from the Wiki page linked.