Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

1 Answer 1

up vote 10 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
1  
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

 
discard

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.