Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<chrono>
- #include<thread>
- void printAnim(int arr[][6], int x, int y, int startX = 0, int startY = 0) {
- if (startX != x+1 || startY != y+1)
- system("cls");
- std::cout << "Reaching: " << x << " " << y << '\n';
- if (startX != x+1) {
- for (int i = 0; i < 6; i++) {
- if (i == startX)
- std::cout << "->";
- for (int j = 0; j < 6; j++)
- std::cout << arr[i][j] << " | ";
- std::cout << std::endl;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(600));
- printAnim(arr, x, y, startX + 1);
- }
- else if (startY != y+1) {
- for (int i = 0; i < 6; i++) {
- if (i == startX)
- std::cout << "->";
- for (int j = 0; j < 6; j++) {
- if (j == startY && i == startX)
- std::cout << "@" << arr[i][j] << " | ";
- else
- std::cout << arr[i][j] << " | ";
- }
- std::cout << std::endl;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(900));
- printAnim(arr, x, y, startX, startY + 1);
- }
- }
- int main() {
- int arr[6][6];
- for (int i = 0; i < 6; i++)
- for (int j = 0; j < 6; j++)
- arr[i][j] = i + j;
- printAnim(arr, 3, 4);
- }
Add Comment
Please, Sign In to add comment