Today was tree planting day. At first I was like, OKAY GIVE EVERY TILE A TREE WITH A CHANCE of 0.5, but that looked but ugly, so I thought of something else. I changed up my “Map generator” a bit so that instead of giving out “Tiles” it gives out a value between one and hundred, and I do the title choosing in my “TileGrid” class (which makes a lot more sense).
Now, to plant my trees, I seeded another world, and used the values of the mapgenerator to choose where to place trees. This way, just like I use the map generator to make water appear together, with sand at the edges, I now use it to make trees appear together, with bushes along the edges. It works pretty fine! Here is a screenshot of the world zoomed out:
http://img534.imageshack.us/img534/3538/unzoomedwithtrees.png
As you can see the trees form nice little woods! Which is pretty cool.
I also split all the parameters of my map generation so that I can easily load different “prefabs” for different terrains, and I added another bit to the terrain creation, for more randomization, which is what I dubbed “Cliff” generation, it works kind of like this:
//For the amount of times I want to add a "Cliff"
for(int i=0;i<cliftimes;i++)
{
//Choose random point
pointX=genValue(WIDTH);
pointY=genValue(HEIGHT);
//Choose random "intensity" depending on the parameter "Clifmult"
mult=genValue(clifmult);
//For every point
for(int x=0;x<WIDTH;x+=1)
{
for(int y=0;y<HEIGHT;y+=1)
{
int t=distance(x,y,pointX,pointY);
//This time instead of doing the Cos( ), I do a 2/(.5*(t+1)), so it's basicly a formula of the shape 1/t, which results in a nice and high peek!
value[x][y]+=(int)(5*mult*(2/(.5*(t+1)))+mult*5*(1/(t+1)*Math.sin(t/5+90)));
}
}
}
This piece of code makes it possible to create nice islands, here’s an example of my island biome:
http://img710.imageshack.us/img710/3893/uglyislands.png
As you can see, the cliff script is still, pretty ugly, I circled in red the ugly sudden rock formations it creates so I will have to tweak that to make it better. My goal with this addition is to make it possible for cliffs to appear next to the water (So that I can later add pretty waterfalls), but it isn’t working yet : (. I’m thinking of doing something with “Erosion”, evening out the low slopes, and extremizing the high slopes, but I’ll have to look into that
Here is my swamp “biome” which does look pretty:
http://img839.imageshack.us/img839/7343/swamp.png
It’s “initialization” code looks something like this:
//SWAMP
case 3:
//"random" multiplier, decides the randomness
ranmult=50;
//Laketimes and lakemult determines the number of "Lake" constructions (The Cos(t)-Cos(.5t)) itterations
laketimes=12;
lakemult=10;
//Determines the amounts of cliffs, which is still 0 since they are ugly
cliftimes=0;
clifmult=0;
//How many times to Anti-alias
aatimes=5;
break;