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: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:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21

//For the amount of times I want to add a "Cliff"for(inti=0;i<cliftimes;i++) {//Choose random pointpointX=genValue(WIDTH);pointY=genValue(HEIGHT);

//Choose random "intensity" depending on the parameter "Clifmult"mult=genValue(clifmult);//For every pointfor(intx=0;x<WIDTH;x+=1) {for(inty=0;y<HEIGHT;y+=1) {intt=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: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

//SWAMPcase3://"random" multiplier, decides the randomnessranmult=50;//Laketimes and lakemult determines the number of "Lake" constructions (The Cos(t)-Cos(.5t)) itterationslaketimes=12;lakemult=10;//Determines the amounts of cliffs, which is still 0 since they are uglycliftimes=0;clifmult=0;//How many times to Anti-aliasaatimes=5;break;

I felt rather unhappy with my map generation, in terms of making it possible to create infinte maps with it, so I decided to try something completely else!It's a bit based on what Damocles is doing, here is what the code about looks like to give an idea:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

publicdoublegetAAPoint(intx, inty, intaa) {//Base caseif (aa<=0) returngetPoint(x,y);//Calculate a "stepsize", which is kind of like how big the cell I'm using isdoublestepsize=Math.pow(2,aa);//return the top left corner of my current rectangle and call this function again with a lower "aa" which results in a lower stepsizereturn(getPoint((int)(x/stepsize),(int)(y/stepsize)) +getAAPoint(x,y,aa-1)); }

So for example getAAPoint(x,y,7), would first take the value of the left upper corner of a 128x128 square (2^7-*), (As do all points in this rectangle!), next I do the same for the 64x64 square this is in, then for the 32x32 square it is in, then 16x16, 8x8, 4x4, 2x2 1x1. I think you'll get what I mean, although my explanation is really vague. At the moment it looks reallllly shitty , but I'm sure that with more work, and maybe a tad of AA it is going to look good:The square structure is reaally easy to spot at the moment, but oh well! I'm thinking of maybe trying something like this with circles or something, although I have no idea how I would subdivide the map in circles, but it seems like a funny idea, and in my opinion, as a hobby, programming has to remain fun.

I'm making progress! I will show my progress in pictures, because a picture speaks a thousand words and stuff:That was my first step, within every square, I choose a point, and I then draw circles arround it using sin(distance to the point). This looks incredibly shitty! Hooray, but now we add another circle, in a smaller rectangle, half the size the other one, and we get the following:So that's already looking a bit better, but still has a lot of jagged edges and uglyness, but I thought OH WHATEVER, JUST DO THAT A LOT OF TIMES AND I"LL SEE WHAT IT LOOKS LIKE.Somehow it looks pretty good, don't ask me about the theory behind it. I'm now trying to aproximate how the map looked before with this new method. I think with some smoothing I can get pretty near, but I have so far not used smoothing.

The benefit of the new method is, that I just have a function getMapPoint(x,y) that returns the height of a point on the map, without requiring any prior knowledge on the map or anything. It's fast too! I'm still thinking about how I'm going to do the smoothing fast.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org