Donnerstag, 11. Oktober 2012

Finalizing the height map

It's almost done. Just a few more switch-cases and it's good to go.

Today I finally understood this blog post (the one I mentioned in the last post)  or at least found a way to use it in my own game.

Let's resume how I managed the heightmap graphix so far.
For each of the edges and corners, I added 2^n to a byte value to find out which tile there has to be. Then I put that value in a switch statement to apply the appropriate graphic. In the end, that looked something like this:

case 11:
case 15:
case 43:
case 47:

Now that's not very efficient... But now I got how it can be down easier. Yay :D So I changed some function here, some other thingy there and it worked w/o any bug. Hooray for me! Now I first check the edges: if there's a different height, I'll have to apply some graphics, so I don't need to check the corners. If the height is the same, I check the corners. The calculation for the cases is pretty much the same, but now I only need 32 cases, not up to 256. All that's left to do is to clean up the code and get rid of all those unnecessary cases now.

The next thing to do after that will be the transition between the tile types.

Oh, and I need better graphics. Definitely...

Cheerio,
Wachmacher

PS: here are some screenshots of the finished height map:

A map with a lower zoom for the nosie generato -
zoomed out for better view

A map with a lower zoom for the noise generator -
zoomed out for a better view

A normal view of a map. Height map's done, yay!
Though it isn't very pretty yet. And water doesn't need it.




Mittwoch, 3. Oktober 2012

(Very) Small steps

So I had this problem with adding the height graphics to the borders of the maps.
For each tile, I check all the adjacent tiles to see which heights they are and add the corresponding graphic. Of course this doesn't work for the borders, since no map knows about the heights of the other maps. So I had to add a Dictionary (an array doesn't work here, since I need the coordinates 55/1 etc and nothing in between - please comment if there I miss something) for the border tiles, calculating the noise value for the adjacent tile check.

How many stupid errors one can do is simply amazing. I not only copied the parameters, having the octave value divided by 2.5 two times instead of just one (I do this for variation, so the height map is different from the tile distribution), I also interchanged various variables, esp. x and y values, subtracted 1 where it really shouldn't be subtracted, and so on. But, finally I got it working and learned a lot about stupid mistakes you can do.

Now I'm adding the rest of the graphics. I do this via a switch statement. Each of the 8 adjacent tiles get one value (1, 2, 4...) and adding the values for a single tile will tell me which graphic I have to use. I found the idea in some post I can't find atm and tried to adopt it. They managed to reduce the number of possible cases from 255 to 16 by using bits for each state of each adjacent field, while I actually have about 25, number still rising. But my system is a bit more complicated *sigh*.

Well, I'm just happy that I found all bugs (hopefully) and can continue to add all the cases/graphics for the height map.

So long
Se Wachmacher