Start of 2D Terrain Generation and Perlin Noise
Initially when I started working with Perlin noise I was using grey scale values to display elevation. So the darker the area the lower the elevation. I also played around with smoothing the noise. The smoother the noise the less differentiation occurs in the height. But I figured for now I wanted to show more on one screen. Check out the images below for the different maps.
Since I currently do not have a chunk loading system or any way to move around the map, I have no way to test generating more than one screen worth of data. In the future I want to have a chunk loading system in place. Initially I would load 9 chunks of the map. The center map where the player is and its 8 neighbor chunks. Then as the character moves I would need to load and unload chunks from memory. This may lead to some problems with the edges of the chunks not matching up with terrain height and biome type. I am not sure of that until I get to that point. I have not started work on the chunk system yet but I think it is one of my next steps.
So, my initial maps just show different noise levels in grey scale. Then I added some color in the next maps to show that water would be the lowest elevation, then sand for beaches, then grass was green, and the grey area for mountains, and white for snow caps. From there I moved onto generating another noise map for moisture levels. I had to use another random seed of noise so the maps were not identical. Then I also changed the increment to smooth out the moisture differently than the elevation map. Most of which will change again once I can produce smaller sections of the overall map using chunks. Once I had both maps setup I merged the outputs together into my algorithm. Then I created different biomes based on the elevation and the moisture level at a specific location. I gave a specific color to each biome. Then I started to get some weird outputs. It took a long time before I realized that I was not adding the different octaves of the noise. Octaves are the number of levels of detail you want your Perlin noise to have. I was only generating one level. Now that I am using a higher number of octaves and adding them together, I am getting a much better result.
Current Biomes:
The biomes currently are: ocean / water, beach, scorched earth, bare, tundra, temperate desert, shrubland, grassland, temperate deciduous forest, temperate rain forest, subtropical desert, tropical seasonal forest, tropical rain forest, snow, and taiga. Each biome is represented by a different color on the map. I may raise or lower the number of biomes in the future. For now this was for testing purposes.
In the near future I am probably going to add more layers of abstraction to the final map. I need a way to produce rivers effectively as well as a way to place trees, bushes, stones, and other objects. I also would like to add a temperature / latitude map to make biomes limited by the temperature as well. This may be harder because I want the map to load dynamically. I will most likely have to determine what the max map size would be in order to add poles and equators. Then I would need a system to chose the starting point of the map, so that the player was not always starting in a specific biome or temperature based solely on the latitude. I also need to work on the system of not only generating the terrain data but then taking that data and translating each pixel to a tile. Currently my maps are not very detailed and don’t include all the data. But, I think I will start working on the basic system to going from a pixel map of colors to a map of tiles that will most likely be 16 pixels wide by 16 pixels tall. I may make it 32 but I have not decided yet.
I have worked a lot so far this week on the noise generation for the maps. But I will also continue to work on some art for the game. I have been working on the character art but I still have to finish the front and back views in grey scale before I move to coloring the character. I also need to work on more tiles for the map. Including more ground tiles for different biomes. Tiles for rock, snow, water, etc. I will also need to work on a tile system and an animated tile system. The game is in such early stages that I basically need to build everything, and as I do I will be adding the progressions here.
Screenshots of the map work so far:
Start of 2D Terrain Generation and Perlin Noise Read More »