Last month, I experimented a lot in game development using cocos2d for the iPhone, especially on moving and modifying sprites. However, vertices and polygons are still new stuff for me.
I developed an algorithm that creates a set of points. I now want to use them to create my 2D terrain. Here is how it looks like when I connect the points in java, so that you can get the idea
The points are connected with lines. However a real game terrain is a shape that is colored or has a texture overlayed, right? For example:
How could I use my points to create such a terrain?
What I tried so far is I created an array and filled it with my points. I pass this array to this method
void ccDrawPoly ( const CGPoint * vertices, NSUInteger numOfVertices, BOOL closePolygon )
draws a poligon given a pointer to CGPoint coordiantes and the number of vertices measured in points. The polygon can be closed or open
This actually draws a plain shape. But from the blue picture it looks like there is not one shape but many.
Please share you knowledge on how to create 2d game terrain.
Based on the two good answer I have following result