Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make a simple 2d terrain with just a few bumps and height changes:

terrain with le car

I thought about just using random numbers to describe the height of a certain vertex, but I don't see how I can make one mesh from this. I'm looking for a way to find the vertex and indices buffers for the terrain.
How do I do this?

share|improve this question
up vote 11 down vote accepted

Create a triangle strip. You could have your random heights at intervals equal to t. So the triangle strip would then consist of you alternating between the height vertices (with y being random and x equal to t * iteration) and vertices that go along the bottom (with y being constant and x also equal to t * iteration).

enter image description here

Naturaly, the distance between each vertex pair doesn't have to be constant, this is just an example of the implementation.

share|improve this answer
Good answer ! . – bobobobo May 3 '12 at 1:13
I thought about how to do this and this answer makes it pretty simple. This actually helps me out with making random asteroid objects. – Azaral May 3 '12 at 1:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.