Advertisement
Guest User

Untitled

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