I'm trying to move upto 30 balls in 3 groups around a circuit using for commands and switches. This is to save on using 30 switches 1 for each ball. However, the problem is that the changes in direction aren't acting on each ball but on the lead ball in each group. As each change of direction occurs the problem intensifies and ends up with balls all over the screen going in every direction. Instead of politely following the lead ball and turning the corners as appropriate.

This is the code segment in question.

Code:
for (n=0; n<3; n++){
    switch (sphere){
     case 0:
     roll[n] = roll[n];
     break;
     case 1:
     glPushMatrix();
     roll[n] = roll[n]+0.1f;
     glTranslatef(roll[n],0,0);
     glutSolidSphere(0.2,40,40);
     glPopMatrix();
    break;
    case 2:

    roll[n]=roll[n]+0.1f;
    glPushMatrix();
    glTranslatef(1,-roll[n],0);
    glutSolidSphere(0.2,40,40);
    glPopMatrix();
    break;
    case 3:
    roll[n]=roll[n]+0.1f;
    glPushMatrix();
    glTranslatef(-roll[n],-1.5,0);
    glutSolidSphere(0.2,40,40);
    glPopMatrix();
    break;
    case 4:
    roll[n]=roll[n]+0.1f;
    glPushMatrix();
    glTranslatef(0,roll[n],0);
    glutSolidSphere(0.2,40,40);
    glPopMatrix();
    break;
    }

 if(roll[n]>1){
    sphere =2;
    }
if(roll[n]>1.5){
    sphere = 3;
    }
if(roll[n]>2){
sphere=4;
}
if(roll[n]>3){
sphere = 1;
roll[n]=0;
}
}
Any ideas how I can correct this or should I set up an additional file with all thirty switches?

I don't want to use an additional thirty switches in the main file if possible as it will cause the program complexity to get out of hand and debugging will be a nightmare.

I'm sorry but this segment has been changed so many times that all semblance of indentation went out of the window long ago.