Check out this map generator

Download this Random Map Generator. It’s coolio.

Press ‘g’ to toggle between graphics modes.

Number Keys to change gamespeed (0 to pause).

+/- to zoom.

Spacebar to toggle between animal control/free look mode.

Hold mouse to control animal.

The way it works is creating a 2dimensional array of elevation points. This array is like a massive grid, covering the whole map, with an x & y value. Each point is then given a value that represents it’s z, value. This creates an elevation map. Then, there’s a waterLevel value that changes based on an evaporation and a raining variable. If the elevation level is below waterLevel, it is drawn as blue (or grey when raining). If it’s above, it’s drawn as brown (or green, where grassy). The animal checks to see if the square it’s standing on is above or below waterLevel, and that determines if it’s swimming or not. Currently it’s drawn with squares, which looks pretty pixelated. Try pressing ‘g’ though, to see the different modes when zooming.

Anyway, it’d be cool if we could find a way to give the borders between land and water a smoother edge.

How’s everyone else going?

Ben.

One Response to “Check out this map generator”

  1. rob says:

    Ben,

    Great stuff generating the terrain. You might like to have a look at “midpoint displacement” algorithms for generating something a little more natural, i.e., fractal. It’s pretty simple to implement and there are some nice tutorials on-line, e.g., http://gameprogrammer.com/fractal.html

    The usual way to use this sort of algorithm is to generate a heighfield for the whole map and then define a water level, all of the terrain that is below the water level is considered under water. This means that you can define the depth of the water as well and use this to fade between an “underwater land texture” and a “water surface” texture depending on the depth, which can give you nice smooth edges where the land meets the water.

    It is also possible to define different types of land based on the heightfield, e.g., land just above the water level might be sandy, above that grassland, above that trees, etc., all the way up to snowy mountain tops.

    If I’m reading your code correctly, it looks like you’ve already started defining a vector field in the water for simulating fluid flow. Wow!!! That was quick. Can’t wait to see what you do with it.

    -RoB-

    PS: Guys, I concerned that this is starting to look like a one-man show on the blog. Please, please, please, could everyone else start posting more stuff here so that everyone has a better idea of how the project is progressing.

Leave a Reply

You must be logged in to post a comment.