Advertisement
Guest User

Untitled

a guest
May 19th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. string config = "config.txt";
  2.     string creature = "creature.txt";
  3.     ifstream configin;
  4.     ifstream creaturein;
  5.     int type = 0;
  6.    
  7.     configin.open(config.c_str());
  8.     creaturein.open(creature.c_str());
  9.  
  10.  
  11.     int choice = 0;int WIDTH = 0; int HEIGHT = 0;
  12.     bool torus;
  13.     HANDLE hOut;
  14.     hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  15.    
  16.         SetConsoleTextAttribute(hOut, FOREGROUND_RED | FOREGROUND_INTENSITY);
  17.     cout << "      WELCOME TO LARRY'S GAME OF LIFE! \n\n\n";
  18.     SetConsoleTextAttribute(hOut, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  19.  
  20.     cout << " What would you like to do for board config? \n"
  21.          << "1. - By Default\n"
  22.          << "2. - Configure Board \n";
  23.     cin >> choice;
  24.          if (choice == 2)
  25.              {
  26.             SetConsoleTextAttribute(hOut, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
  27.  
  28.             cout << "\nBoard Size( Width By Height): ";
  29.             cin >> WIDTH >> HEIGHT;
  30.             cout << "\nWould you like it to be a torus?: (1 for true or 0 for false)";
  31.             cin >> torus;
  32.              }
  33.          system ("cls");
  34.           SetConsoleTextAttribute(hOut, FOREGROUND_BLUE | FOREGROUND_INTENSITY);
  35.        
  36.         if (WIDTH == 0){
  37.         configin >> WIDTH >> HEIGHT >> torus;
  38.         }
  39.         plane *myplane = new plane(WIDTH,HEIGHT,torus);
  40.          
  41.     cout << "What would you like to do for the Organisms\n"
  42.          << "1. - Default\n"
  43.          << "2. - Configure Manually\n";
  44.          
  45.     cin >> choice;
  46.             int x = 0;
  47.             int y = 0;
  48.          if (choice == 2)
  49.             {
  50.           SetConsoleTextAttribute(hOut, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
  51.  
  52.             cout << "\nPlease Enter X and Y Coordinates for Producers (enter -1 to exit Producer)\n";
  53.             while (x != -1)
  54.             {
  55.             cin >> x >> y;
  56.             myplane->addOrg(x,y,1);
  57.             cout << endl;
  58.             }
  59.             cout << "\nPlease Enter X and Y Coordinates for Consumers (enter -2 to exit Consumer)\n";
  60.             while (x != -2)
  61.             {
  62.             cin >> x >> y;
  63.             myplane->addOrg(x,y,2);
  64.             cout << endl;
  65.             }
  66.  
  67.             system ("cls");
  68.         }
  69.          
  70.          else
  71.          {
  72.             creaturein >> x >> y >> type;
  73.             x = x-1;y = y-1;
  74.             while (creaturein.good())
  75.             {
  76.                 myplane->addOrg(x,y,type);
  77.                 creaturein >> x >> y >> type;
  78.                 x--;y--;
  79.  
  80.             }
  81.             system ("cls");
  82.          }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement