Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <chrono>
- #include <thread>
- using namespace std;
- int main()
- {
- const char* CSI = "\033[";
- cout << CSI << "?25l"; //Remove cursor from screen
- for (int x = 1, y = 1, x1 = 10, y1 = 10, dx = 1, dy = 1, dx1 = 2, dy1 = -2; ; x += dx, y += dy, x1 += dx1, y1 += dy1)
- {
- if (y > 24 or y < 1) { dy = dy * (-1); y += dy; }
- if (x > 79 or x < 1) { dx = dx * (-1); x += dx; }
- if (y1 > 24 or y1 < 1) { dy1 = dy1 * (-1); y1 += dy1; }
- if (x1 > 79 or x1 < 1) { dx1 = dx1 * (-1); x1 += dx1; }
- //std::cout << CSI << "2J" << std::endl; //clear screen
- // \033[y;xH = position output to y,x \033[XXm = change text color to XX color, \033[0m = change color to default
- std::cout << CSI << y << ";" << x << "H" << CSI << 31 << "m" << "*" << CSI << "0m" << std::endl;
- std::cout << CSI << y1 << ";" << x1 << "H" << CSI << 33 << "m" << "*" << CSI << "0m" << std::endl;
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- std::cout << CSI << y << ";" << x << "H" << CSI << 30 << "m" << "*" << CSI << "0m" << std::endl;
- std::cout << CSI << y1 << ";" << x1 << "H" << CSI << 30 << "m" << "*" << CSI << "0m" << std::endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment