Day_3Making it rainIn my biome definitions I added humidity as one of the factors. I wanted humidity to only depend on rainfall in my simplistic world, but how does one calculate rainfall?
I originally did not plan on spending a lot of time on calculating rainfall. But I ended up making it way more advanced than originally anticipated.
First of all, clouds are evaporated water. So, let us start by isolating all the water in the world:
The water periodically spawn clouds. Clouds should disperse themselves, this will help them "get around corners", which will be useful later. For now the simulation just generates "blobs" around the water sources, which is perfect for what I want.
(For the more technical minded, the spread is basically Gaussian distribution, it is almost same algorithm you use to blur images)
Clouds are not static objects, they follow wind currents around globe. I don't want to simulate wind currents as it would make it a bit complicated. Instead I just cheat and all two main wind currents. A global west to east wind, and random coherent "any direction" wind. This way clouds will start forming pretty cool looking paterns:
(On this screenshot it is just the "west east" wind)
The east to west wind should only effect the cloud perodically as well, it creates much needed variation in the cloud density:
As it is right now, clouds only spawn from water sources. But, as the world does not wrap around right now, it will create quite a lot of deserts in the western parts of the world. So, instead I implemented random clouds to randomly "drift" in from the western border using perlin noise:
(You can't really see it much, but it adds to a better looking map)
Next step is to add random wind currents. This is done by generating 3d perlin noise, and moving through the "third" dimension to simulate change. Using this noise value, a random direction vector is calculated and the cloud is moved in this direction. Since the noise is "coherent" the movement direction is also coherent. Here only clouds above 0.5 in weight are drawn. These clouds will be making the terrain "wet".
Time to test out some rainfall, and see which parts of the world get wet, and what parts are left dry.
(Blue = high humidity, Black = Ocean (Ignored for now), Dark green = low humidity, Light green = mountain/low humidity)
Now, lets put everything together:
Perfect, this is what I wanted when I first started the project!
Alright, time to load in some test resources and distribute it on the map.
Resources like biomes, are also loaded from a XML file. This makes it very easy to add more resources when I feel the need for it. They follow this scheme:
<resource>
<name> Fish </name>
<requiresBiome> Ocean </requiresBiome>
<havestable> TRUE </havestable>
<mineffectRadius> 100 </mineffectRadius>
<maxeffectRadius> 250 </maxeffectRadius>
<minoutput> 0.1 </minoutput> <!-- 0.1 t / month -->
<maxoutput> 5.0 </maxoutput> <!-- 5.0 t / month -->
<type> FOOD </type> <!-- Other posibilities are LUXORY, WEAPON, MATERIAL -->
<scarcity> 2000 </scarcity> <!-- 1 in 2000 tiles -->
<duration> 7 </duration> <!-- Lasts 7 months before it rots, used later, for gameplay -->
<!-- Ignored for now.. -->
<duration_modifier factor="2.0" modType="resource"> Salt </duration_modifier> <!-- Doubles duration -->
<output_modifer factor="2.0" modType="biome"> Tropical Ocean </output_modifer> <!-- Doubles output if on tropical ocean -->
</resource>
After loading the resources, and planting them on the map. The result looks like this:
(Sorry, it is a bit cluttered, but it is to demonstrate the distribution of resources!)
For now modifiers are not in effect, but it would be easy to hook up. It is on the TODO list in my eclipse project!
That is it for Day_3, next up I will add some more resources, and work a bit on the cities, hopefully I can implement path finding to create trade routes between cities!
Feel free to leave a comment, feedback is always appreciated.