Terrain Generation Example

This example program shows you how to generate terrain using a simple hill algorithm. It stores values which represents the map in TMAP, which you can use in a game. I can't tell you how to integrate it into your game, but feel free to ask questions about the generator.

How it works
The algorithm creates a scaled down version of the screen. The scale is based on RES; if you set it to 1, you'll get a perfect resolution map (but it'll take forever). The default value of 4 creates 4X4 blocks. Random sized hills are then placed on the map. The hills build upon other hills, so eventually the terrain starts to get rough. This is all done in @RAISE. Afterwards, the map is normalized so that the entire terrain falls within an expected range (0-1). The terrain is flattened (even though the method is called @SHARPEN), then converted into tile information. Each tile has a value within the range 1-REGIONS, where REGIONS is the amount of colors (regions) the map can take on. Finally, the map is just drawn to the screen. This isn't a very good explanation, but this website should make everything clear: http://www.stuffwithstuff.com/robot-frog/3d/hills/index.html.

Variables for generation

 * RES: Changes the resolution of the map. Larger = more blocky (try to make it a power of 2, like 1, 2, 4, 8, 16, etc.)
 * MINRAD/MAXRAD: The minimum and maximum radius of the hills. Mess with these values to change the form of the land.
 * WATER: Specifies the percentage of area which should generally be covered with water.
 * SAND,GRASS,MOUNT,SNOW: Specifies the breakup of the leftover area after the water is filled. Note that these should add up to 100!
 * GRASSL/GRASSH: Breaks up grass lands into two regions: low and high. These percentages should add up to 100 (these percentages are the portion of grass broken up into these two categories).
 * MOUNTL/MOUNTH: Same as GRASSL/GRASSH, but for mountains. Should add up to 100.
 * DEBUG: Set to 0 to remove terrain generation messages.
 * RAISENUM: Determines the number of hills to raise. Mess with this to change the form of the land.

This isn't the best way to generate terrain, but Petit Computer is slow, so it's fine I guess. Let me know if you have questions!