#04 - Natural Features
For the past week I've been working on a scalable registry system to assign settings to biomes for more dynamic, streamlined, and easily adjustable world generation, and my God it's been a task. After starting from scratch for the third time, I've finally made it to a place I'm happy with.
By adding a build function to the biome class itself, I can essentially funnel all the data I want into a single method to create an entire environment, and using nested custom classes, I can get as detailed as I like (within the limits of reasonable computation). So far, I've only made mild progress on natural features to add to the landscape, such as trees, flowers, and grass. It's an ever changing process though, since I'm constantly realising things I want to add and adjust within the simulation of the world. Although I'm trying not to get too distracted from actually sorting out the tilemap, because even now, the world generates in a way I'm not completely sold on, and there are no connecting textures for smooth biome transitions. Hell, the tiles I'm using are still placeholders. I'd like upgrade the visuals but until I've worked out how I'll actually handle the tile rendering.
Anyway, I figured I'd show how the biome generation works. On entering the world, each of the biomes is registered to a central biome registry as a biome object. This is created within a BuildBiome() class, which has three main branches for three main biome types, that being plains, swamp, and desert. Partnered with some boolean values, we can branch off to determine whether, for example, a plains biome is cold and has trees, leading to a snowy forest, or if it is neither of those but has flowers, leading to a flower meadow. Along and at the end of these branches, different features, which were registered prior to the biomes, are added to a list which is sent through to the biome object at rendered to the world.
It may seem convoluted, and it may well be (I'm not a fan of excessive use of if statements) but it winds up being the least amount of code and quickest method I've tried. But this is only really half of it. This whole system only serves to pair data to biomes to later be called on during actual world generation.
The next section of code called is to establish a climate range, which serves the fundamental world generation methods using perlin noise. I'm still exclusively using temperature and precipitation to generate the world, and the climate range pairs a min/max for each to a biome which is called for each tile on generation. The ranges are determined by a table I made but want to translate into code, because right now it would require a complete rewrite or massive sacrifice of a particular biome (or 2) to add in another biome, which is obviously not ideal.
It's hard coded and will inevitably be rewritten, but it works for now. The only issue now is harnessing the data now paired with the biomes. The biome data will contain natural feature data, which points towards types of trees that can spawn and the chance that it will. The issue comes from randomness. The current save data is so clunky and slows down chunk generation terrible, so I need to change it to only save changes made to the natural terrain, but that requires consistent world generation across the board. The implication there is that everything, from biomes to tree generation, should derive from the world seed itself. I do have a dedicated seed utility script so maybe I'll just build on that and make a nice, central, static set of methods to use across the board. Or maybe it'll be vastly more complicated. Who knows.
At this point I've exhausted myself on biome generation, so I'll be taking a bit of a detour further into the save data problem. To really test this out though, I'll have to introduce ways to change the terrain which is it's own can of worms. It's all about laying strong foundations right now. I'm setting up systems that I'll be using throughout the rest of development and I'd really rather avoid having to rewrite anything so crucial to the structure of the game. Lots of big things to do.
---
That's it for now though, so until the next time, take care.
Khôra
A top down 2.5D pixel survival sandbox & eco-sim.
Status | In development |
Author | Dormarr |
Genre | Simulation, Survival |
Tags | 2D, Indie, Open Source, Open World, Pixel Art, Sandbox |
More posts
- #06 Terrain Texturing66 days ago
- #05 Colour Mapping Tiles71 days ago
- #03 - Expanding BiomesSep 02, 2024
- #02 - Prelim ArtworkAug 30, 2024
- #01 - World Generation FoundationAug 30, 2024
- #00 - Initial Ideas & ConceptsAug 30, 2024
Leave a comment
Log in with itch.io to leave a comment.