Last time, I promised that in this chapter we’d start generating trees and forests. I’ll show you the forests soon, but before we go any further with this project, we need to move this over into a real graphics engine. As neat as it is, the command line isn’t exactly fast/powerful enough to draw the detail we’ll need as we keep going. To this end, I decided to work with libGDX because it’s a framework I’m already somewhat familiar with. It’s basic enough that I have a lot of graphical freedom and efficiency, without having to do a lot of the background work myself. It’s also useful because it lets me create a helpful visual demonstration of how “brightness” in Perlin noise translates to “elevation” in our map:

On the left, you can see what the Perlin noise actually looks like: a 2D map of gray values, with a higher value corresponding to a brighter pixel. On the right is the final result with those gray values mapped to different terrain types, and the middle has both overlaid to make what’s going on a bit clearer. Like I somewhat failed to explain last time, the brighter a pixel is, the higher we say its elevation is. Everything below a certain value is water. As we get higher, the terrain becomes sand, dirt, grass, and finally snow. With that out of the way, we canĀ almost move onto trees, but first we need to talk about time travel.
Continue reading “Adventures in Terrain Generation, Chapter 2: Into the Woods”