Advertisement
Guest User

Untitled

a guest
May 10th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.09 KB | None | 0 0
  1. // ConsoleApplication3.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <string>
  7. #include <random>
  8. #include <sstream>
  9. #include <conio.h>
  10. #include <windows.h>
  11.  
  12. using namespace std;
  13.  
  14. int row;
  15.     int col;
  16.     int i;
  17.     int j;
  18.     int GameArray[8][8];
  19.  
  20. void Menu()
  21.  
  22.  
  23. {
  24.  
  25.     int Option;
  26.  
  27.     cout << endl;
  28.     cout << "Welcome To My Game" << endl;
  29.     cout << endl;
  30.     cout << "Please Choose From The Following" << endl;
  31.     cout << "Play (1)" << " " << "Quit (2)";
  32.     cout << endl;
  33.     cout << endl;
  34.     do
  35.  
  36.     {
  37.         cout << "Choice = ";
  38.         cin >> Option;
  39.  
  40.         if (Option >= 2)
  41.         {
  42.             cout << endl;
  43.             cout << "GoodBye!!!" << endl;
  44.             cout << endl;
  45.             exit(1);
  46.         }
  47.         {
  48.             if (Option == 1)
  49.                 cout << endl;
  50.             cout << "Good luck" << endl;
  51.             cout << endl;
  52.         }
  53.            
  54.        
  55.             if (Option != 1 && Option != 2);
  56.  
  57.            
  58.  
  59.     } while (Option != 1 && Option != 2);
  60. }
  61.  
  62. void GameBoard()
  63. {
  64.  
  65.  
  66.     //load array with 1s
  67.     for (i = 0; i < 8; i++) {
  68.         for (j = 0; j < 8; j++) {
  69.             GameArray[i][j] = 1;            // Works
  70.  
  71.         }
  72.     }
  73.  
  74.     //Bomb = B
  75.     //Mines = M
  76.     GameArray[0][0] = 3;
  77.     GameArray[0][7] = 3;
  78.     GameArray[7][0] = 3;
  79.     GameArray[7][7] = 3;
  80.     GameArray[0][1] = 3;
  81.     GameArray[7][3] = 3;
  82.     GameArray[7][1] = 3;
  83.     GameArray[7][6] = 3;
  84.     GameArray[7][4] = 3;
  85.     GameArray[0][6] = 3;
  86.  
  87.  
  88.     //=========================================================
  89.  
  90.  
  91.     //load array with 1s
  92.     for (i = 0; i < 8; i++)
  93.  
  94.     {
  95.         for (j = 0; j < 8; j++)
  96.  
  97.         {
  98.             if (GameArray[i][j] == 1)
  99.                 std::cout << 'M';
  100.             if (GameArray[i][j] == 2) // Works
  101.                 std::cout << '*';
  102.             if (GameArray[i][j] == 3) // Works
  103.                 std::cout << 'B';
  104.  
  105.  
  106.         }
  107.         std::cout << std::endl;
  108.     }
  109.  
  110.  
  111.  
  112.  
  113.     std::cout << std::endl;
  114.     std::cout << "Enter a row" << std::endl;
  115.     std::cin >> row;
  116.     std::cout << "Enter a column" << std::endl;
  117.     std::cin >> col;
  118.     std::cout << std::endl;
  119.  
  120.  
  121.  
  122.     if (GameArray[row][col] == 3) // Works
  123.     {
  124.         std::cout << "You're dead!" << std::endl;
  125.         (GameArray[row][col] = 3);
  126.         system("pause 10");
  127.     }
  128.    
  129. }
  130.  
  131. int main()
  132.  
  133.  
  134.  
  135. {
  136.  
  137.     Menu();
  138.    
  139.     GameBoard();
  140.  
  141.  
  142.  
  143.  
  144.     return 0;
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement