Drawing the Ground

Hello,

I am trying to draw a set of vertices that are randomly generated at different heights and at different widths.

The problem is that is not what is happening when i run my code.

I only get a straight line half way down the middle of the screen.

Here is the code.

THIS IS RANDOM.CPP AND WILL BE USED TO GENERATE RANDOM NUMBERS.

#include<ctime>
#include<cstdlib>

// This function is used to seed the random umver so they are unpredictable
void start_random()
{
static bool seeded = false;
if (!seeded){
srand((unsigned)time(NULL));
seeded = true;
}
}

// Generate a random float in the range -1 to +1
float rnd(){
start_random();
return (-1) + (float)rand() / 16384;
}

// Generate a random float in the specified range
float rnd(float rangemin, float rangemax){
start_random();
return rangemin + (float)rand()*(rangemax - rangemin) / 32768.0;
}

// Generate a random integer in the specified range(0…range-1)
int rnd(int range){
start_random();
return rand() % range;
}

THIS IS THE GROUND CLASS

class Ground
{
public:
Ground();
void show();
float currentH(float x)
{
int index = x * nopoints/width;
return points[index];
}
private:
static const int nopoints = 50;
static const int width = 500;
float x, y, w, h;
float points[nopoints];
};

HERE IS THE CONSTRUCTOR AND SHOW FUNCTION

Ground::Ground()
{
//x = X;
//y = Y;
//w = width;
//h = height;

for (  int i = 0; i &lt; 50; i++)
{
	points[i] = rnd(50,100);
}

int landing_pad = rnd(50,100);

float h = points[landing_pad];

for (int i = landing_pad; i &lt; landing_pad + 10; i++)
{
	points[i] = h;
}

}

void Ground::show() //draws ground
{
glBegin(GL_LINE_STRIP);
glColor3f(0,0,0);

	glVertex2f(0, -0.5);
	for ( int i = 0; i &lt; 50; i++)
	{
		glVertex2f(i, points[i]);
	}
	glVertex2f(500, -0.5);
glEnd();

}

FINALLY THERE IS A POINTER AND AN init() FUNCTION THAT CREATES A NEW GROUND AND IS CALLED TO MAIN

POINTER
Ground *surface = NULL;

INIT() FUNCTION
void init()
{
surface = new Ground;
}

DISPLAY FUNCTION

void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0, 0, 0);
bk->draw(0,1,500,500);
surface->show();
a.show();
a.gravity();
glFlush();
}

MAIN FUNCTION
int main(int argc, char**argv)
{
glutInit(&argc, argv);
glutInitWindowSize(500, 500);
glutCreateWindow(“Lunar Lander”);
init();
glClearColor(1, 1, 1, 1);
glutKeyboardFunc(WASD);
glutDisplayFunc(display);
glutSpecialFunc(ARROWS);
glutIdleFunc(display);
glutMainLoop();
return 0;
}

THERE ARE OTHER PARTS OF THIS PROGRAM THAT IS WHY THERE IS A glutSpecialFunc IN MAIN and a.show() IN DISPLAY ETC.

Any help or ideas on some issues in this code would be much appreciated