It’s been a while since I had the time to play around with the Blender Game Engine, but I decided I’d take a little bit of my time to experiment with procedural world generation. Ultimately, I’d like to make a Harvest Moon style farming-sim, but for now, it’s just the world generation.
Originally, I’d made the world split into 16 x 16 chunks, and when you reached the edge of one, the entire screen would pan to the next area (like the original Legend of Zelda). I figured this way you’d only ever have to display 512 tile on screen at one time, and the BGE would have no problem handing that. Turns out, the BGE could actually handle much more than that, so I opted to just have dynamic world spawning/deleting as you run around.
While the world is completely flat, I found the easiest way to generate the biomes was to use a height factor. Once everything below a certain height was set to water, and everything above a certain height set to mountains, the remainder of the map is generated based on rainfall and temperature factors. I used a Python implementation of Perlin noise to generate the maps – although simply having one scale level of noise wasn’t enough, because everything looked too round. To get round this, I scaled the noise to a smaller resolution, and added it to the higher resolution to get both overall highs and lows, as well as local variance. The results were pretty good for what I needed, it may need tweaking in the future.
I was considering fully moving over to Unity for all my projects from now on, but it looks like the ol’ BGE still has a bit of life in it. Next up, farming!