This tutorial explains how generate terrains using heightmaps and the hills algorithm I came up with to create these heightmaps. It does not explain how to draw a terrain in 3d; there are other far better tutorials out there for that. At the end of the tutorial, I have included a complete C++ class that will generate terrains of any given size using this algorithm.