I have just finished my tic tac toe game but wanted to make it look nicer so i added some colors at the winning scene...

cout << "congratulations player 1!" << endl;
            cout << "[W][I][N]" << endl;
            cout << "[W][I][N]" << endl;   // checking if the game has been won by O
            cout << "[W][I][N]" << endl;
            system("color 01");
            Sleep(400);
            system("color 01");
            Sleep(400);
            system("color 02");
            Sleep(400);
            system("color 03");
            Sleep(400);
            system("color 04");
            Sleep(400);
            system("color 05");
            Sleep(400);
            system("color 06");
            Sleep(400);
            system("color 07");
            Sleep(400);
            system("color 08");
            Sleep(400);
            system("color 09");
            Sleep(400);
            getch();
            return 0;

I was wondering if there is anyway that i can make the colors loop while its waiting for the user to input a character so that the colors don't just stop?

Member Avatar for iamthwee

I was wondering if there is anyway that i can make the colors loop while its waiting for the user to input a character so that the colors don't just stop?

Yeah... My immediate thoughts are to store the color strings in an array and then loop through them.

If using a std::string you might need to convert it with .c_str() when calling a system command.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.