Steve Criddle - February 2000
This is my first stab at writing a Java applet.
I have written this program in several different languages over the years,
so it seemed like a good project with which to learn Java. I'm quite
pleased with the results.
Using the program
The controls probably don't need to be explained.
Simply type a number in the box and click Go!. The program
will generate a landscape based on that number. Alternatively, click
the Random button and the program will choose a number for you.
How it works
The landscape is on a 33x33 grid. The
program starts by setting the height of all four corners to zero.
Then it takes points halfway between the existing points, calculates the
average of the points either side and adds a random amount to that.
Once it has done all four sides, it then calculates the centre point.
Having done that, it does the same thing
at half the resolution (4 times), then again at half that resolution
(16 times) and so on until every cell in the 33x33 grid has a number in
To draw the landscape, the program starts
at the back and works forward (so the program doesn't have to worry about
hidden lines). For each sqaure the program calculates the average
height of the four points and uses this as a fifth central point.
The program then draws each of the four resulting triangles and colours
them according to some simple rules.
If your browser supports HTML5, I have now written a variation of Frax that runs in a canvas object. Click on the link above to see it.
If the triangle is below water level, the
height is set to water level and the colour is set according to the depth
(ranging from blue to black).
If the top of the triangle is exactly at water
level, the colour is set to orange (sand).
If the triangle is above water level and below
a certain height, its colour is between green and light brown, depending
on its height and steepness.
If the triangle is above a certain height,
its colour ranges from light grey to white (snow) depending on its height.