Astro
04-13-2003, 01:48 PM
I have tried absolutely everything with this piece of code to get it working without success. The output is a scrambled cube but it does not show each rotation as it happens. What am I missing??? If you can think of anything at all, please let me know.
Thanks.
/* Process the main menu when the right mouse button is pressed*/
static void selectMainMenu(int selection)
{
int numb_of_rotations = 1; //maximum number of rotations
int i;
switch (selection)
{
case MAIN_MENU_QUIT:
exit(0); break; //terminates the application
case 1: /* stop cube spinning */
spinStop();
sx=sy=sz=0;/*makes sure no part of the cube is selected when spinning stops*/
break;
case 2: /* help */
//help();
/* windows system call that tells windows to open the help text file */
system("notepad C:\Program Files\Microsoft Visual Studio\MyProjects\RubikCubefyp\interface.txt");
break;
case 3:
for( i=0; i < numb_of_rotations; i++)
{
rotcounter = 1;
for(int j=0; j< numb_of_rotations; j++) //to ensure all axis are randomized
{
scramble_cube(); /* call to scramble cube function */
//glutPostRedisplay();
}
//rotcounter = 0;
//sx=sy=sz=0;//nothing is selected, no grey areas
}
rotcounter = 1 ;
break;
case 4: /* reset */
resetcube();
sx=sy=sz=0;/*makes sure no part of the cube is selected when reset*/
break;
case 5: /* spin cube */
spinDisplay();
sx=sy=sz=0;/*makes sure no part of the cube is selected when spinning starts*/
break;
case 6: /* solve */
// solve_cube();
break;
}
/* Scrambles the rubik's cube */
void scramble_cube(void)
{
int axis ;
char char_axis;
int direction;
axis = rand() % 3;//selects a random axis
cout << "axis = " << axis << endl ;
switch (axis)
{
case 0:
char_axis = 'z';
//rotcounter = 0;
//inputUpdate() ;
break;
case 1:
char_axis = 'x';
//rotcounter = 0;
//inputUpdate();
break;
case 2:
char_axis = 'c';
//rotcounter = 0;
//inputUpdate() ;
break;
}
cout << "char_axis = " << char_axis << endl;
Keyboard(char_axis, 0, 0);
direction = rand() % 3 ; //creates a ramdom direction
//from rotate_selected in main
if(direction == 0) //no dierection at start
rotate_selected(-1); //counter-clockwise rotation
else
rotate_selected(1) ; //clockwise rotation
//glutPostRedisplay();
}
}
Thanks.
/* Process the main menu when the right mouse button is pressed*/
static void selectMainMenu(int selection)
{
int numb_of_rotations = 1; //maximum number of rotations
int i;
switch (selection)
{
case MAIN_MENU_QUIT:
exit(0); break; //terminates the application
case 1: /* stop cube spinning */
spinStop();
sx=sy=sz=0;/*makes sure no part of the cube is selected when spinning stops*/
break;
case 2: /* help */
//help();
/* windows system call that tells windows to open the help text file */
system("notepad C:\Program Files\Microsoft Visual Studio\MyProjects\RubikCubefyp\interface.txt");
break;
case 3:
for( i=0; i < numb_of_rotations; i++)
{
rotcounter = 1;
for(int j=0; j< numb_of_rotations; j++) //to ensure all axis are randomized
{
scramble_cube(); /* call to scramble cube function */
//glutPostRedisplay();
}
//rotcounter = 0;
//sx=sy=sz=0;//nothing is selected, no grey areas
}
rotcounter = 1 ;
break;
case 4: /* reset */
resetcube();
sx=sy=sz=0;/*makes sure no part of the cube is selected when reset*/
break;
case 5: /* spin cube */
spinDisplay();
sx=sy=sz=0;/*makes sure no part of the cube is selected when spinning starts*/
break;
case 6: /* solve */
// solve_cube();
break;
}
/* Scrambles the rubik's cube */
void scramble_cube(void)
{
int axis ;
char char_axis;
int direction;
axis = rand() % 3;//selects a random axis
cout << "axis = " << axis << endl ;
switch (axis)
{
case 0:
char_axis = 'z';
//rotcounter = 0;
//inputUpdate() ;
break;
case 1:
char_axis = 'x';
//rotcounter = 0;
//inputUpdate();
break;
case 2:
char_axis = 'c';
//rotcounter = 0;
//inputUpdate() ;
break;
}
cout << "char_axis = " << char_axis << endl;
Keyboard(char_axis, 0, 0);
direction = rand() % 3 ; //creates a ramdom direction
//from rotate_selected in main
if(direction == 0) //no dierection at start
rotate_selected(-1); //counter-clockwise rotation
else
rotate_selected(1) ; //clockwise rotation
//glutPostRedisplay();
}
}