Advertisement
Guest User

Untitled

a guest
Aug 5th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3. #include <cstdlib>
  4. #include <Windows.h>
  5. #include <time.h>
  6.  
  7. void xy()
  8. {
  9.     HANDLE hout;
  10.     COORD Position;
  11.     hout = GetStdHandle(STD_OUTPUT_HANDLE);
  12.     Position.X = 0;
  13.     Position.Y = 0;
  14.     SetConsoleCursorPosition(hout, Position);
  15. }
  16.  
  17. class GameFunctions
  18. {
  19. private:
  20.     int x = 19, y = 9;
  21.     char player = 'X';
  22.     char cash = '$';
  23.     char object = 'U';
  24.    
  25.     public:
  26.         char field[30][30];
  27.  
  28.         GameFunctions() {
  29.  
  30.            
  31.             for (int a = 0; a < 20; a++)
  32.             {
  33.                 for (int b = 0; b < 20; b++)
  34.                 {
  35.                     field[a][0] = '|';
  36.                     field[a][18] = '|';
  37.                     field[a][b] = ' ';
  38.                 }
  39.             }
  40.         }
  41.         void DrawField()
  42.         {
  43.             for (int a = 0; a < 20; a++)
  44.             {
  45.                 for (int b = 0; b < 20; b++)
  46.                 {
  47.                     std::cout << field[a][b];
  48.                     if (b >= 19) {
  49.                         std::cout << std::endl;
  50.                     }
  51.                 }
  52.             }
  53.         }
  54.  
  55.         int gx() { return x; }
  56.         int gy() { return y; }
  57.         char gplayer() { return player; }
  58.    
  59.  
  60.  
  61. };
  62.  
  63. int main()
  64. {
  65.     srand(unsigned(time(nullptr)));
  66.     GameFunctions *Take = new GameFunctions();
  67.    
  68.     bool ongoing = true;
  69.    
  70.     Take->field[Take->gx()][Take->gy()] = Take->gplayer();
  71.  
  72.  
  73.     do {
  74.         xy();
  75.         Take->DrawField();
  76.    
  77.  
  78.         std::cin.get();
  79.     } while (ongoing);
  80.  
  81.  
  82.    
  83.    
  84.     return 0;
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement