Advertisement
Ansaid

Передвижение консольного курсора

Aug 10th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. /*Передвижение консольного курсора*/
  2. #include "pch.h"
  3. #include <iostream>
  4. #include <conio.h>
  5. #include <windows.h>
  6.  
  7. using namespace std;
  8.  
  9. class Draw
  10. {
  11. private:
  12.     COORD position;
  13.     HANDLE hConsole;
  14. public:
  15.  
  16.     Draw()
  17.     {
  18.         position.X = 0;
  19.         position.Y = 0;
  20.         hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
  21.     }
  22.  
  23.     void set_cursor(int x, int y)
  24.     {
  25.         position.X = x;
  26.         position.Y = y;
  27.         SetConsoleCursorPosition(hConsole, position);
  28.     }
  29.  
  30.     void Hello()
  31.     {
  32.         cout << "Hello!";
  33.     }
  34. };
  35.  
  36. int main()
  37. {
  38.     setlocale(LC_ALL, "Russian");
  39.     Draw game;
  40.    
  41.     game.set_cursor(35, 12);
  42.     game.Hello();
  43.  
  44.     game.set_cursor(35, 14);
  45.     game.Hello();
  46.  
  47.     game.set_cursor(35, 17);
  48.     return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement