PDA

View Full Version : truly rand points

omega arts
05-31-2002, 06:30 PM
I am making a program similyer to the one in openGL game programming but i want to make completly rand points each time the user hits the 1 key. Here is the code now it makes rand points but I want it to draw 50 points then draw 50 NEW points when the one key is pressed. As the way it is now it draws one point then clears it then draws the next...
Here is the code that I think is important to my problem it is openGL with WIN32 if you can help me plz tell how to do it or if you need more code/info tell me
thx
if (holdType == points)
{

glBegin(GL_POINTS);
int xArray [50];
int yArray [50];
for (int i=0;i<50;i++)
{
srand(GetTickCount());
xArray[i-1] = rand()%60;
yArray[i-1] = rand()%60;
}

for (int j=0;j<50;j++)
{

glColor3ub(rand()%256,rand()%256,rand()%256);
glVertex3f(xArray[j-1],yArray[j-1],0);
}

glEnd();

}
case WM_CHAR:
{
switch (toupper(wParam))
{
case VK_ESCAPE:
{

PostQuitMessage(0);
return 0;
break;
}

case '1':
holdType = points;
return 0;
break;

Jambolo
05-31-2002, 08:26 PM
int xArray [50];
int yArray [50];
for (int i=0;i<50;i++)
{
srand(GetTickCount());
xArray[i-1] = rand()%60;
yArray[i-1] = rand()%60;
}

First of all, the [i-1] is likely to cause big problems. Where is the value stored when i = 0?

[This message has been edited by Jambolo (edited 05-31-2002).]