samedi 30 mars 2019

RANDOM OBJECTS AT THE SAME TIME

I am trying to create 5 objects at the same time. However, I want it to stop after creating 5 objects at the same time. I tried to use COUNT variable to count the targets. However, it does not work.

void drawTarget(target_t arr[]){

srand(time(NULL));


int i;

 r = rand() % 256;
 g = rand() % 256;
 b = rand() % 256;


for(i=0; i<MAX; i++){


    tX = rand() % 256;
    tY = rand() % 256;

    arr[i].xTarget = tX;
    arr[i].yTarget = tY;
    glColor3ub(r,g,b);
    glBegin(GL_TRIANGLES);
    glVertex2f(arr[i].xTarget + 20, arr[i].yTarget = tY+ 50);
    glVertex2f(arr[i].xTarget + 40,arr[i].yTarget = tY + -180);
    glVertex2f(arr[i].xTarget + 100, arr[i].yTarget = tY + -20);
    glEnd();

    count++;

}



while(count < MAX)
count++;



glColor3f(0,0,1);

}




Aucun commentaire:

Enregistrer un commentaire