Hello there, I’m new here, and thought I’d share something isntead of only being here to ask annoying questions.
I’m working on some random map generation for a game I am working on, and I was thinking that some sharing of thoughs on map generation would be nice, since my stuff so far is far from perfect.
What I am doing at the moment, is rather simple, and would be best described in a snippet of code:
//Repeat for a set number of times
for(int i=0;i<laketimes;i++)
{
//Pick a point somewhere in the map
pointX=genValue(WIDTH);
pointY=genValue(HEIGHT);
for(int x=0;x<WIDTH;x+=1)
{
for(int y=0;y<HEIGHT;y+=1)
{
//For every value, take the distance
int t=distance(x,y,pointX,pointY);
//And then add to the map's height, a number depending on Cos(Distance*90)
value[x][y]+=(int)(100.0*Math.cos(t/10+90));
}
}
}
I also added in a bit of white noise over the whole thing, and afterwards I smooth it out, by for every x,y assigning the average of the surrounding values. I do this two times but I guess that is all down to flavor, here’s a pic of my method:
http://img16.imageshack.us/img16/1082/randommap.png
As you can see, everything seems to be a bit circling arround the lakes.
So anyone have past experience with generating maps?