Can a 'Raw String' be replaced by another once printed?

0

I have three raw strings:

string wawe1 = R"(
              ^                       ^         ^
          ^   |           ^           |         |
          |   |     ^     |         ^ |   ^     |
          |   |     |     | ^       | |   |   ^ |
          |   |   ^ |   ^ | |       | | ^ |   | |
          |   |   | |   | | | ^   ^ | | | | ^ | |
          | ^ |   | | ^ | | | | ^ | | | | | | | |
          | | | ^ | | | | | | | | | | | | | | | |
         ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++)";
string wawe2 = R"(
                    ^         ^       ^
                    |     ^   |   ^   |
            ^       |     |   |   |   |     ^   ^
            |       | ^   |   | ^ |   | ^   |   |
          ^ |   ^   | |   |   | | |   | |   |   |
          | |   |   | |   |   | | |   | | ^ | ^ |
          | |   | ^ | |   | ^ | | | ^ | | | | | |
          | | ^ | | | | ^ | | | | | | | | | | | |
          | | | | | | | | | | | | | | | | | | | |
         ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++)";
string wawe3 = R"(
                        ^       ^       ^
              ^   ^     |       |       |     ^
              |   |     |       |   ^   |     |
            ^ |   |     |     ^ |   |   |     |
            | |   |     | ^   | | ^ |   | ^   |
          ^ | |   |   ^ | |   | | | |   | | ^ | ^
          | | | ^ |   | | |   | | | |   | | | | |
          | | | | |   | | |   | | | | ^ | | | | |
          | | | | | ^ | | | ^ | | | | | | | | | |
         ++-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-++)";

And so I execute them:

for (int i = 0; i < 100; ++i) {
            cout << wawe1 << 'r' << flush;
            Sleep(1000);
            cout << wawe2 << '\r' << flush;
            Sleep(1000);
            cout << wawe3 << '\r' << flush;
            Sleep(1000);
        }

But I do not get the effect I want, I would like them to be replaced one by another, to give it a movement effect, instead I get it printed one after the other.

Is it possible to do what I'm looking for?

    
asked by Oscar D 06.05.2018 в 01:43
source

1 answer

0

The solution to my problem was to continue using the RAW strings and replace it with another one by means of the row where it was, to get the coordinates was by trial and error:

void gotoxy(int x, int y){
    HANDLE hcon = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD dwPos;
    dwPos.X = x;
    dwPos.Y = y;
    SetConsoleCursorPosition(hcon, dwPos);
}

So implement it;

int i = 0;
while (i < 5) {
    gotoxy(1,27); cout << wawe1 << '\r' << flush;
    Sleep(500);
    gotoxy(1,27);cout << wawe2 << '\r' << flush;
    Sleep(500);
    gotoxy(1,27);cout << wawe3 << '\r' << flush;
    Sleep(500);
    i++;
}

And I get something like that which is what I was looking for, a small animation: link

    
answered by 08.05.2018 / 01:44
source