Yeah yeah.. You’ve heard it all before. Terrain generation. Perlin noise. All that jazz. Yes, well, I have gone and done it again, and I have used this attempt at 2D terrain generation to try and get a better understanding of the control I have over Perlin noise, and how to sculpt it to represent terrain that looks and feels real.
I’m using Processing in this example, as its a nice and quick way to get some graphics output and lets me focus on the math side of things. Its also got the Processing.js port which allows the same sketches to be run in web browsers, which is kick-ass. Processing is a language built on top of Java that allows you to fallback to using Java when and if you need to. Check it out.
This is the first attempt at rendering the terrain, its a Perlin generation of the top level in 1D, and then simple unmodified or scaled perlin generation in 2D for the caves. Its pretty boring.
My second attempt used a new multiplication of values technique to produce more realistic caves. You can see in the follow screenshot my first encounter with repeating perlin noise. At this stage, I was not sure what was causing the repeat. John suggested that it was a limited set of data, and the nature of the noise()
function in Processing being designed to produce limited data for seamless wrapping. This turned out to be true, and I made changes later.
After looking at various other games, specifically Terraria, I realised that the desired variety of caves and general terrain could not be done in a single pass. Thus, I started doing “SmallCaves” and “LargeCaves” generation, which started showing some more interesting results:
The latest samples I have use a technique that Jason recommended, which was to scale the X and Y for certain caves differently in order to achieve more “walkable” caves. This produced a good result. At this high level view (zoomed out) the terrain looks a little funny. Once the terrain is scaled and tiled correctly, it should look and feel a lot better whilst playing.
I’d love some feedback on this. Any comments, suggestions or anything. I’m not entirely sure the current terrain will be final, and it will probably need to be tweaked, and I would love to hear your ideas.
Coming up next, I will be adding new tile types with various colours and game modifiers. The first modified tile “Water” is currently in deveopment, it has a blue colour, and adjusts movement to 0.5 actual speed, to simulate the motion in water.