Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <iomanip>
- using namespace std;
- bool hasFinished = false;
- void clearScreen();
- void movable_car();
- int main() {
- movable_car();
- hasFinished ? cout << "You finished" : cout << "You did not finish!";
- return 0;
- }
- void clearScreen()
- {
- HANDLE hOut;
- COORD Position;
- hOut = GetStdHandle(STD_OUTPUT_HANDLE);
- Position.X = 0;
- Position.Y = 0;
- SetConsoleCursorPosition(hOut, Position);
- }
- void movable_car() {
- CONSOLE_SCREEN_BUFFER_INFO csbi;
- unsigned int frames;
- GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
- frames = csbi.srWindow.Right - csbi.srWindow.Left + 1;
- for (size_t i = 0; i < frames - 1; i++) {
- clearScreen();
- cout << setw(i - 5) << " .--------." << endl;
- cout << setw(i) << "___/_____|___ \\____" << endl;
- cout << setw(i + 1) << "* _ - | _ O" << endl;
- cout << setw(i) << "'--(_)-------(_)--'" << endl;
- }
- hasFinished = !hasFinished;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement