Generating Cliffs for 2d Game

Nathaniel Inman walks through the algorithm necessary to generate random cliffs for 2d video games.

Generating Cliffs for 2d Game

Source code available on github here.\n\nA recurring problem in 2d games is how to represent depth. In isometric games this is easily solved but in discretely top-down games it's harder to solve. After doing a lot of research I fell onto a simple idea: do the best you can insinuating the depth and leave the rest to the imagination. Here's the algorithm I used to create 2d top-down cliffs:

  • Create a small map of perlin noise and a wide map of perlin noise. Add the two together and give the large map a weight of 3 with the small a weight of 1 and render the result with different breakpoints. This is ref map A.
    • Less than 0.01 on A is deep water
    • Less than 0.11 on A is shallow water
    • Less than 0.18 on A is sand
    • The rest on A is floor
  • We create a large map of perlin noise to conjoin atop the existing map to allow cliffs to show up at certain breakpoints within the existing breakpoints of A. This is ref map B.
    • Less than 0.25 on A and less than 0.2 with 10% is special rock
    • Less than 0.25 on A and less than 0.2 is rock