May 2020

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 »

Grass Block Tiles

Currently I am programming my own Java Game / Engine for a top down procedural generated world game. It is very early in the project and I wanted to share the entire process with everyone. Since it is so early in the project I wanted to get started working on something. Currently I am working a full time job and also teaching a couple classes a year as an adjunct professor of computer science. But for the summer I am not teaching, which allows me to work more on this project. Also with the current situation in the world I don’t know how long I will be working my current job, which is why I am starting this new venture in my life.

This weekend I spent some time working on some grass tiles as well as a bush tile for my game. I was happy with the way some of the basic grass tiles and the final bush tiles turned out. I don’t think I will use all of them but it is a start. This coming week I want to start working on the sprite sheet for the main character. I typically start with a gray-scale sprite and then add the color once I am happy with the way it looks. I know I may be working a bit out of order but I like to mix up working on art and programming so it stays interesting.

Also in this coming week I am going to be looking into using Perlin Noise or another method to start working on terrain generation. I think it is going to be a long road but I would like the game to have procedural generated 2D terrain. That way each time you generate a world it will be unique. Once I figure out the Perlin Noise part of the generation then I can move on to displaying the proper tiles depending on the values. I also will probably implement more layers of procedural generation to handle rivers and other necessary parts of the overall generation. For instance tree and brush locations. I have never done it before and I am looking forward to learning how it works. I know so far that I have not done much but I had to start somewhere.

Grass Tile Assets

Grass Block Tiles Read More »