Advertisement
Garey

Moving car

Oct 18th, 2017
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. bool hasFinished = false;
  8.  
  9. void clearScreen();
  10. void movable_car();
  11.  
  12. int main() {
  13.  
  14.         movable_car();
  15.  
  16.         hasFinished ? cout << "You finished" :  cout << "You did not finish!";
  17.  
  18.     return 0;
  19. }
  20.  
  21. void clearScreen()
  22. {
  23.     HANDLE hOut;
  24.     COORD Position;
  25.  
  26.     hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  27.  
  28.     Position.X = 0;
  29.     Position.Y = 0;
  30.     SetConsoleCursorPosition(hOut, Position);
  31. }
  32.  
  33. void movable_car() {
  34.  
  35.     CONSOLE_SCREEN_BUFFER_INFO csbi;
  36.     unsigned int frames;
  37.  
  38.     GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
  39.     frames = csbi.srWindow.Right - csbi.srWindow.Left + 1;
  40.  
  41.     for (size_t i = 0; i < frames - 1; i++) {
  42.         clearScreen();
  43.         cout << setw(i - 5) << "     .--------." << endl;
  44.         cout << setw(i) << "___/_____|___ \\____" << endl;
  45.         cout << setw(i + 1) << "*    _   - |   _   O" << endl;
  46.         cout << setw(i) << "'--(_)-------(_)--'"  << endl;
  47.  
  48.     }
  49.  
  50.     hasFinished = !hasFinished;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement