So I just noticed I haven’t even opened the map generator project for a looong time so decided to open-source it instead of just letting it rot on my hdd. I mean why not, right?
-Where is it?
If you ever work on it, please do fork it on bitbucket or somehow let me know about what you’re doing & your process. I just would love to know.
-Are you actively working on Map Generator?
Nope not really. I believe I haven’t done anything for months now. I just lost interest I guess, it happens. I never finish whatever I do.
-Well I don’t get this part of the code, can you help me?
Of course, I would love to do whatever I can. Just mail me and ask whatever you have on your mind. [More]
So we’ve created rivers in last part right? Now that we have elevation and river , now we can calculate moisture which we’ll use for biomes later. I guess this will be a short post , since calculating moisture is pretty much same as calculating elevations. Pretty similar iterations , almost same.
The main idea here is to set river moisture a static value and then iterate through all corners and decrease this value as the corner gets further away from the river. Then we’ll also set center ( polygon ) moisture as the average of it’s corners’ moisture , easy peasy.
OK so I’ll start with our first method , CalculateCornerMoisture() [More]
So now that we’ve calculated elevations and somewhat created the Y axis on our map , we can now create some rivers! Rivers will turn or boring looking island into a much better , interesting environment. We’ll also use rivers and watersheds to calculate moisture and biome later on so we definitely need them.
We’ll use a simple method to generate them , we’ll get a few random points on the map and then create the river down to the ocean or a lake using the elevation datas. The number of rivers and the starting points will all be random for now.
First of all , we’ll iterate through all corners and create a “Downslope” property for them. Downslope will be the adjacent corner with the lowest elevation or in other words , the way which water will run.
Then we’ll do pretty much same for the calculation of watersheds. Iterate through all corners and set the Watershed of the Downslope corner as the current corners Watershed until it reaches water.
Then we’ll actually create the rivers , take a random corner between statically set elevations ( like 0.3 and 0.9 , since we don’t want rivers starting at the beach or at the top of the mountain ) , follow downslopes till water and calculate river width depending on the watersheds we calculated earlier.
Huh I don’t even know why did I bother to explain it like this , it should be much more easy to explain with code! [More]
If you read the previous part ( Part 2.5 ) you probably already know I decided to just convert Amit’s code from now on and keep my personal additions at minimum. Hopefully I’ll also be able to post more frequently , just because of this too.
But again let me remind you this , since we’re working on a totally different framework and somewhat different structure , it won’t be exact same as Amit’s original code. There are still some differences like order of calculations or WPF related extra code here and there but the algorithms and stuff will be almost same.
Also if you remember Part 2.5 was totally optional , even not recommended so we’ll keep working on Part 2 now.
This is what we had at the end of Part 2 and now , in this post, we’ll talk about and implement elevation calculation. [More]
I'm aware this series are coming along pretty slow , apologies for that. One of the main reasons for that , is I'm working on a few different version of this project at the same time. You see this series are based on WPF but actually I switched to XNA some time ago , and it is the main branch for me at the moment. But since WPF and XNA is so different , I just can't switch to XNA for blogging like that.
That's pretty much why I decided to make this WPF version , the exact same as Amit's original work. I will not go into my own implementations of various stuff like elevation distribution , I'll just convert Amit's code. I'm doing things my own way in XNA anyway ( and probably I'll talk about that in future too ).
But before that , there is one last personal thing I want to talk about in this WPF series , so I'll call this Part 2.5. It's totally optional and actually I even suggest not use this one in your project but still something cool and good to know.
Remember the island we got at the end of last post? It was looking pretty decent right? Well but in my XNA work , I came to a point where I had to do something about those strong and sharp coast line. [More]