Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.18 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. #include <windows.h>
  4. #include <string>
  5. #include <cmath>
  6. #include <cstdlib>
  7. #include <vector>
  8. #include <time.h>
  9. using namespace std;
  10.  
  11.  
  12. void gotoxy(int x, int y)
  13. {
  14. COORD p = { static_cast<int>(x), static_cast<int>(y) };
  15. SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), p);
  16. }
  17. void resetInitText();
  18. void locationCalc(std::string a, int boats, std::string b, int calc[]);
  19. void printer(int player, int array[], vector<vector <int>>& board, int& tracker, int diff);
  20. void checker(int& player, int array[], vector<vector <int>> board, int playerDiff);
  21. void resetText(int playerDiff);
  22. void hitregplayer(int i, int j, vector<vector <int>> plocation, int& timeshit, int& pHit);
  23. void hitregcomputer(int i, int j, vector<vector <int>> clocation, int& timeshitc, int& cHit, int& alreadyHit, int cAlreadyHit[8][8]);
  24. void computerBrains(int& x, int& y, int playerDiff);
  25. void hitPrinter(int x, int y, int player, int hit, int diff);
  26. void gameLoop(vector<vector<int>> playerOne, vector<vector <int>> playerTwo, int playerDiff, int multiPlayer);
  27.  
  28.  
  29. int main()
  30. {
  31. resetInitText();
  32.  
  33.  
  34. int i;
  35. int j;
  36. int diff; //used for board array size. Easy = 6x6, Medium = 8x8, Hard = 10x10//
  37. int multiPlayer;
  38.  
  39. cout << "Enter in 1-Player or 2-Player. (1-Player = 1, 2-Player = 2)";
  40. cin >> multiPlayer;
  41. resetInitText;
  42.  
  43.  
  44. cout << "What difficulty would you like to play on? (Easy = 1, Medium = 2, Hard = 3)" << endl;
  45. cin >> diff;
  46. int shipsSizes[6] = { 2,3,3,4,5,4 };
  47. vector<vector <int>> playerOne;
  48. vector<vector <int>> playerTwo;
  49. if (diff == 1) {
  50. playerOne.resize(6, vector<int>(6, 0));
  51. playerTwo.resize(6, vector<int>(6, 0));
  52.  
  53. }
  54. else if (diff == 2) {
  55. playerOne.resize(8, vector<int>(8, 0));
  56. playerTwo.resize(8, vector<int>(8, 0));
  57.  
  58. }
  59. else if (diff == 3) {
  60. playerOne.resize(10, vector<int>(10, 0));
  61. playerTwo.resize(10, vector<int>(10, 0));
  62.  
  63. }
  64.  
  65. char letters[10] = { 'A','B','C','D','E','F','G','H','I','J' };
  66.  
  67. //initializes the sizes of the boats, the second one is the computer's boats//
  68.  
  69.  
  70.  
  71.  
  72. string temp[2];
  73.  
  74. /*the calc[4] array holds ship placement and is accessed throughout the game
  75. calc[0] = x placement
  76. calc[0] = y placement
  77. calc[0] = direction
  78. calc[0] = size of ship
  79. */
  80. int calc[4];
  81.  
  82. int game = 17;
  83.  
  84. int loopState = 0;
  85. int tracker = 0;
  86.  
  87. resetInitText();
  88.  
  89. //vvv This for loop couts<< the original empty board vvv//
  90. if (diff == 1) {
  91. for (i = 0; i < 6; i++) {
  92.  
  93. for (j = 0; j < 6; j++) {
  94. cout << playerOne[i][j] << " "; //<<< couts player's board
  95. }
  96. cout << (i + 1) << " | " << (i + 1) << " "; //<<< couts spacer and vertical number coords on board
  97. for (j = 0; j < 6; j++) {
  98. cout << playerOne[i][j] << " "; //<<< couts computer's board, but uses same array because its all zeros
  99. }
  100. if (i == 5) {
  101. cout << endl;
  102. }
  103. for (j = 0; j < 6; j++) {
  104. if (i == 5) {
  105. cout << letters[j] << " "; //<<< couts horizontal letter coords on player board
  106. }
  107. if (j == 5 && i == 5) {
  108. cout << " | "; //spacer
  109. }
  110. }
  111.  
  112. for (j = 0; j < 6; j++) {
  113. if (i == 5) {
  114. cout << letters[j] << " "; //<<< couts horizontal letter coords on player board
  115. }
  116. }
  117. cout << endl;
  118. }
  119. }
  120. else if (diff == 2) {
  121. for (i = 0; i < 8; i++) {
  122.  
  123. for (j = 0; j < 8; j++) {
  124. cout << playerOne[i][j] << " "; //<<< couts player's board
  125. }
  126. cout << (i + 1) << " | " << (i + 1) << " "; //<<< couts spacer and vertical number coords on board
  127. for (j = 0; j < 8; j++) {
  128. cout << playerOne[i][j] << " "; //<<< couts computer's board, but uses same array because its all zeros
  129. }
  130. if (i == 7) {
  131. cout << endl;
  132. }
  133. for (j = 0; j < 8; j++) {
  134. if (i == 7) {
  135. cout << letters[j] << " "; //<<< couts horizontal letter coords on player board
  136. }
  137. }
  138. if (i == 7) {
  139. cout << " | "; //spacer
  140. }
  141. for (j = 0; j < 8; j++) {
  142. if (i == 7) {
  143. cout << letters[j] << " "; //<<< couts horizontal letter coords on player board
  144. }
  145. }
  146. cout << endl;
  147. }
  148. }
  149. else if (diff == 3) {
  150. for (i = 0; i < 10; i++) {
  151.  
  152. for (j = 0; j < 10; j++) {
  153. cout << playerOne[i][j] << " "; //<<< couts player's board
  154. }
  155. if (i == 9) {
  156. cout << (i + 1) << " | " << (i + 1) << " ";
  157. }
  158. else {
  159. cout << (i + 1) << " | " << (i + 1) << " "; //<<< couts spacer and vertical number coords on board
  160. }
  161. for (j = 0; j < 10; j++) {
  162. cout << playerOne[i][j] << " "; //<<< couts computer's board, but uses same array because its all zeros
  163. }
  164. if (i == 9) {
  165. cout << endl;
  166. }
  167. for (j = 0; j < 10; j++) {
  168. if (i == 9) {
  169. cout << letters[j] << " "; //<<< couts horizontal letter coords on player board
  170. }
  171. }
  172. if (i == 9) {
  173. cout << " | "; //spacer
  174. }
  175. for (j = 0; j < 10; j++) {
  176. if (i == 9) {
  177. cout << letters[j] << " "; //<<< couts horizontal letter coords on player board
  178. }
  179. }
  180. cout << endl;
  181. }
  182. }
  183. //^^^ This for loop couts<< the original empty board ^^^//
  184.  
  185.  
  186. tracker = 0;
  187.  
  188. //vvv This for loop places down the player's 1 ships vvv//
  189. for (i = 0; i < (diff + 3); i++) {
  190. cout << "Player 1. Where would you like to place a size [" << shipsSizes[i] << "] ship? (Ex. B7)" << endl;
  191. cin >> temp[0]; //inputs coords for boat placement as a string. Example is "B7", or "C5"
  192. cout << "Player 1. What direction would you like to place that ship? (N,S,E,W)" << endl;
  193. cin >> temp[1]; //inputs direction for boat placement as a string. Example is "N", or "E"
  194. locationCalc(temp[0], shipsSizes[i], temp[1], calc); //this function takes the user inputs, and puts them all into the calc[4] array as integer values
  195. checker(loopState, calc, playerOne, diff); //this 374-checker() function works with the calc[4] array to check if the boat placement is "allowed"
  196. if (loopState == -1) { //if the placement isn't "allowed", a loopState of -1 is returned and forces the player to choose another placement
  197. i--;
  198. cout << "ERROR, Player 1 cannot put a ship there";
  199. Sleep(3000);
  200. loopState = 0;
  201. }
  202. else { //if loopState doesnt come back as -1, then the printer() function is ran
  203. printer(loopState, calc, playerOne, tracker, diff); //the 274-printer() function uses the calc[4] array to "print" the boats onto the board
  204. } //this is only done if the boat placement checked "valid" (see above)
  205. resetText(diff); //this 355-resetText() function resets the text to it's original position, ready for another loop
  206. }
  207. //^^^ This for loop places down the player's 1 ships ^^^//
  208.  
  209. loopState = 0;
  210.  
  211. if (multiPlayer == 1) {
  212. for (i = 0; i < (diff + 3); i++) {
  213.  
  214. srand(time(0));
  215. srand(time(0) * (rand() % 1000) * (rand() % 513) + (i * 6584));
  216.  
  217. calc[0] = rand() % (4 + (2 * diff)); //randomly picks x-coord to place ship
  218. srand(time(0) * (rand() % 1000) + (i * 4584)); //randomizes seed again
  219. calc[1] = rand() % (4 + (2 * diff)); //randomly picks y-coord to place ship
  220. srand(time(NULL) * rand() % 467 + (i * 5584)); //randomizes seed again a second time
  221. calc[2] = rand() % 4; //randomly picks direction to place ship
  222. calc[3] = shipsSizes[2 - i + diff]; //chooses the next size ship to place
  223. //program places them down in opposite order to increase placement speed, hence the [4-i].
  224.  
  225.  
  226. checker(loopState, calc, playerTwo, diff);//checks that the boat placement
  227. if (loopState == -1) { //same process as above, if the placement comes back invalid, then the computer goes back through the randomizing loop
  228.  
  229. i--; //i-- <<<<this causes the loop to run forever, or until the computer chooses a "valid" placement
  230. loopState = 0;
  231.  
  232. }
  233.  
  234. else if (loopState == 0) {
  235. printer(1, calc, playerTwo, tracker, diff); //"prints" the computer's placement after it has found a "valid" ship placement
  236. Sleep(1500);
  237. }
  238.  
  239. }
  240. }
  241. else if (multiPlayer == 2) {
  242. //vvv This for loop places down the player's 2 ships vvv//
  243. for (i = 0; i < (diff + 3); i++) {
  244. cout << "Player 2. Where would you like to place a size [" << shipsSizes[i] << "] ship? (Ex. B7)" << endl;
  245. cin >> temp[0]; //inputs coords for boat placement as a string. Example is "B7", or "C5"
  246. cout << "Player 2. What direction would you like to place that ship? (N,S,E,W)" << endl;
  247. cin >> temp[1]; //inputs direction for boat placement as a string. Example is "N", or "E"
  248. locationCalc(temp[0], shipsSizes[i], temp[1], calc); //this function takes the user inputs, and puts them all into the calc[4] array as integer values
  249. checker(loopState, calc, playerTwo, diff); //this 374-checker() function works with the calc[4] array to check if the boat placement is "allowed"
  250. if (loopState == -1) { //if the placement isn't "allowed", a loopState of -1 is returned and forces the player to choose another placement
  251. i--;
  252. cout << "ERROR, Player 2 cannot put a ship there";
  253. Sleep(3000);
  254. loopState = 0;
  255. }
  256. else { //if loopState doesnt come back as -1, then the printer() function is ran
  257. printer(1, calc, playerTwo, tracker, diff); //the 274-printer() function uses the calc[4] array to "print" the boats onto the board
  258. } //this is only done if the boat placement checked "valid" (see above)
  259. resetText(diff); //this 355-resetText() function resets the text to it's original position, ready for another loop
  260. }
  261. //^^^ This for loop places down the player's 2 ships ^^^//
  262. }
  263. resetText(diff);
  264.  
  265.  
  266.  
  267.  
  268. gameLoop(playerOne, playerTwo, diff, multiPlayer); //this enter's the function "gameLoop()". see line 413
  269.  
  270. return 0;
  271. }
  272.  
  273.  
  274.  
  275. void locationCalc(std::string a, int boats, std::string b, int calc[]) {
  276. int x = 0;
  277. int y = 0;
  278. int size = boats;
  279. int direction;
  280. direction = 5;
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287. if (b == "N" || b == "n") {
  288. direction = 0;
  289. }
  290. else if (b == "E" || b == "e") {
  291. direction = 1;
  292. }
  293. else if (b == "S" || b == "s") {
  294. direction = 2;
  295. }
  296. else if (b == "W" || b == "w") {
  297. direction = 3;
  298. }
  299.  
  300. if (a[0] == 'A' || a[0] == 'a') {
  301. x = 0;
  302. }
  303. else if (a[0] == 'B' || a[0] == 'b') {
  304. x = 1;
  305. }
  306. else if (a[0] == 'C' || a[0] == 'c') {
  307. x = 2;
  308. }
  309. else if (a[0] == 'D' || a[0] == 'd') {
  310. x = 3;
  311. }
  312. else if (a[0] == 'E' || a[0] == 'e') {
  313. x = 4;
  314. }
  315. else if (a[0] == 'F' || a[0] == 'f') {
  316. x = 5;
  317. }
  318. else if (a[0] == 'G' || a[0] == 'g') {
  319. x = 6;
  320. }
  321. else if (a[0] == 'H' || a[0] == 'h') {
  322. x = 7;
  323. }
  324. else if (a[0] == 'I' || a[0] == 'i') {
  325. x = 8;
  326. }
  327. else if (a[0] == 'J' || a[0] == 'j') {
  328. x = 9;
  329. }
  330. else if (a[0] == 'K' || a[0] == 'k') {
  331. x = 10;
  332. }
  333. else if (a[0] == 'L' || a[0] == 'l') {
  334. x = 11;
  335. }
  336.  
  337.  
  338.  
  339. if (a[1] == '2') {
  340. y = 1;
  341. }
  342. else if (a[1] == '3') {
  343. y = 2;
  344. }
  345. else if (a[1] == '4') {
  346. y = 3;
  347. }
  348. else if (a[1] == '5') {
  349. y = 4;
  350. }
  351. else if (a[1] == '6') {
  352. y = 5;
  353. }
  354. else if (a[1] == '7') {
  355. y = 6;
  356. }
  357. else if (a[1] == '8') {
  358. y = 7;
  359. }
  360. else if (a[1] == '9') {
  361. y = 8;
  362. }
  363. else if (a[1] == '1' && a[2] == '0') {
  364. y = 9;
  365. }
  366. else if (a[1] == '1' && a[2] == '1') {
  367. y = 10;
  368. }
  369. else if (a[1] == '1' && a[2] == '2') {
  370. y = 11;
  371. }
  372. else if (a[1] == '1') {
  373. y = 0;
  374. }
  375.  
  376. calc[0] = x;
  377. calc[1] = y;
  378. calc[2] = direction;
  379. calc[3] = size;
  380.  
  381. }
  382. void printer(int player, int array[], vector<vector <int>>& board, int& tracker, int diff) {
  383. int x;
  384. int y;
  385. int i;
  386.  
  387. char box = (char)219;
  388.  
  389. char c;
  390. c = box;
  391. std::string ship(2, c);
  392.  
  393. ship.push_back(c);
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402. if (player == 0 || player == 1) {
  403.  
  404. if (array[2] == 0) {//this places ships if they chose the north direction
  405. for (i = 0; i < array[3]; i++) {//runs a loop that places down all parts of the ship
  406. x = (array[0] * 2) + (18 * player) + player * (diff * 4);
  407. y = (array[1]) - (i); //shifts the placement upwards in the y-direction
  408. gotoxy(x, y);
  409. cout << 1;
  410. board[array[1] - i][array[0]] = 1;
  411. }
  412. }
  413. else if (array[2] == 1) {//this places ships if they chose the east direction
  414. for (i = 0; i < array[3]; i++) {
  415. x = (array[0] * 2) + (i * 2) + (18 * player) + player * (diff * 4); //shifts the placement to the right in the x-direction
  416. y = (array[1]);
  417. gotoxy(x, y);
  418. cout << 1;
  419. board[array[1]][array[0] + i] = 1;
  420. }
  421. }
  422. else if (array[2] == 2) {//this places ships if they chose the south direction
  423. for (i = 0; i < array[3]; i++) {
  424. x = (array[0] * 2) + (18 * player) + player * (diff * 4);
  425. y = (array[1]) + (i); //shifts the placement to the down in the y-direction
  426. gotoxy(x, y);
  427. cout << 1;
  428. board[array[1] + i][array[0]] = 1;
  429. }
  430. }
  431. else if (array[2] == 3) {//this places ships if they chose the west direction
  432. for (i = 0; i < array[3]; i++) {
  433. x = (array[0] * 2) - (i * 2) + (18 * player) + player * (diff * 4); //shifts the placement to the left in the x-direction
  434. y = (array[1]);
  435. gotoxy(x, y);
  436. cout << 1;
  437. board[array[1]][array[0] - i] = 1;
  438. }
  439. }
  440. }
  441.  
  442. }
  443. void resetText(int playerDiff) {
  444. int i;
  445. if (playerDiff == 1) {
  446. for (i = 7; i < 15; i++) {
  447. gotoxy(0, i);
  448. cout << " ";
  449. }
  450. gotoxy(0, 7);
  451. }
  452. else if (playerDiff == 2) {
  453. for (i = 9; i < 15; i++) {
  454. gotoxy(0, i);
  455. cout << " ";
  456. }
  457. gotoxy(0, 9);
  458. }
  459. else if (playerDiff == 3) {
  460. for (i = 11; i < 15; i++) {
  461. gotoxy(0, i);
  462. cout << " ";
  463. }
  464. gotoxy(0, 11);
  465. }
  466. }
  467. void resetInitText() {
  468. int i;
  469. gotoxy(0, 0);
  470. for (i = 0; i < 20; i++) {
  471. gotoxy(0, i);
  472. cout << " ";
  473. }
  474. gotoxy(0, 0);
  475.  
  476. }
  477. void checker(int& player, int array[], vector<vector <int>> board, int playerDiff) {
  478.  
  479. int i;
  480.  
  481.  
  482.  
  483. if (array[2] == 0) {
  484. for (i = 0; i < array[3]; i++) {
  485.  
  486. if (array[1] - i < 0) {
  487.  
  488. player = -1;
  489. }
  490. else if (board[array[1] - i][array[0]] != 0) {
  491. player = -1;
  492. }
  493. }
  494. }
  495. else if (array[2] == 1) {
  496. for (i = 0; i < array[3]; i++) {
  497. if (array[0] + i > 3 + (playerDiff * 2)) {
  498.  
  499. player = -1;
  500. }
  501. else if (board[array[1]][array[0] + i] != 0) {
  502. player = -1;
  503. }
  504. }
  505. }
  506. else if (array[2] == 2) {
  507. for (i = 0; i < array[3]; i++) {
  508. if (array[1] + i > 3 + (playerDiff *2)) {
  509.  
  510. player = -1;
  511. }
  512. else if (board[array[1] + i][array[0]] != 0) {
  513. player = -1;
  514. }
  515. }
  516. }
  517. else if (array[2] == 3) {
  518. for (i = 0; i < array[3]; i++) {
  519. if (array[0] - i < 0) {
  520.  
  521. player = -1;
  522. }
  523. else if (board[array[1]][array[0] - i] != 0) {
  524. player = -1;
  525. }
  526. }
  527. }
  528. }
  529.  
  530.  
  531.  
  532. void gameLoop(vector<vector<int>> playerOne, vector<vector <int>> playerTwo, int playerDiff, int multiPlayer) {
  533. string attackCoords;
  534. int coords[4];
  535. int pHitTimes = 0;
  536. int pHit;
  537. int cHitTimes = 0;
  538. int cHit;
  539. int x, y;
  540. bool win = false;
  541. int alreadyHit;
  542. int cAlreadyHit[8][8];
  543. //the code below runs the loop which is the "game". where both players take turns inputting coords.
  544. //the program inputs the user coords, but the computer randomly chooses coords using the 452-computerBrains() function
  545. //the program uses the 460-hitregplayer() and the 483-hitregcomputer() functions to see if it was a hit/miss
  546. //then it uses the 503-hitPrinter() function to display to the board
  547. int goal = 0;
  548.  
  549. if (playerDiff == 1) {
  550. goal = 12;
  551. }
  552. else if (playerDiff == 2) {
  553. goal = 17;
  554. }
  555. else if (playerDiff == 3) {
  556. goal = 21;
  557. }
  558.  
  559.  
  560. do {
  561. cout << "Player 1. Enter in the coords you wish to attack. (Ex. B7): ";
  562. cin >> attackCoords;
  563.  
  564. locationCalc(attackCoords, 0, "W", coords);
  565. hitregplayer(coords[1], coords[0], playerTwo, pHitTimes, pHit);
  566. hitPrinter(coords[0], coords[1], 1, pHit, playerDiff);
  567. Sleep(200);
  568. resetText(playerDiff);
  569. alreadyHit = 1;
  570. if (multiPlayer == 1) {
  571. do {
  572. computerBrains(x, y, playerDiff);
  573. hitregcomputer(y, x, playerOne, cHitTimes, cHit, alreadyHit, cAlreadyHit);
  574. } while (alreadyHit == 1);
  575. hitPrinter(x, y, 0, cHit, playerDiff);
  576. }
  577. else if (multiPlayer == 2) {
  578. cout << "Player 2. Enter in the coords you wish to attack. (Ex. B7): ";
  579. cin >> attackCoords;
  580.  
  581. locationCalc(attackCoords, 0, "W", coords);
  582. hitregcomputer(coords[1], coords[0], playerOne, cHitTimes, cHit, alreadyHit, cAlreadyHit);
  583. hitPrinter(coords[0], coords[1], 0, cHit, playerDiff);
  584. }
  585.  
  586. Sleep(200);
  587.  
  588. if (cHitTimes == goal || pHitTimes == goal) {
  589. win = true;
  590. }
  591.  
  592. resetText(playerDiff);
  593. } while (win == false);
  594.  
  595. if (pHitTimes == goal) {
  596. cout << "Player 1 won!";
  597. }
  598. else {
  599. cout << "Player 2 won!";
  600. }
  601. Sleep(30000000);
  602. }
  603.  
  604. void computerBrains(int& x, int& y, int playerDiff) {
  605. if (playerDiff == 1) {
  606. srand(time(0));
  607. x = rand() % 6;
  608. srand(time(0) * rand() % 1000);
  609. y = rand() % 6;
  610. }
  611. else if (playerDiff == 2) {
  612. srand(time(0));
  613. x = rand() % 8;
  614. srand(time(0) * rand() % 1000);
  615. y = rand() % 8;
  616. }
  617. else if (playerDiff == 3) {
  618. srand(time(0));
  619. x = rand() % 10;
  620. srand(time(0) * rand() % 1000);
  621. y = rand() % 10;
  622. }
  623.  
  624. }
  625.  
  626. void hitregplayer(int i, int j, vector<vector <int>> plocation, int& timeshit, int& pHit) { /* where location refers to where the player aims, and computer location*/
  627. int u;
  628. int v;
  629.  
  630.  
  631. if (plocation[i][j] == 1) {//clocation refers == true where ship coordinate is
  632. cout << "Hit" << endl;
  633. //alreadyHit[i][j] = 1; //sets alreadyHit as true
  634. //location[i][j] = 0; //resets player target
  635. timeshit++;
  636. pHit = 1;
  637. cout << endl;
  638. cout << endl;
  639.  
  640.  
  641. }
  642. else {
  643. cout << "Miss" << endl;
  644. pHit = 0;
  645.  
  646. }
  647.  
  648. }
  649.  
  650. void hitregcomputer(int i, int j, vector<vector <int>> clocation, int& timeshitc, int& cHit, int& alreadyHit, int cAlreadyHit[8][8]) { /* where colocation refers to where the computer aims, and player location*/
  651.  
  652. if (clocation[i][j] == 1 && cAlreadyHit[i][j] != 1) {//plocation refers == true where ship coordinate is
  653. cout << "Computer attacked at (" << j << ", " << i << ") and hit!." << endl;
  654. //calreadyHit[i][j] = 1; //sets alreadyHit as true
  655. //colocation[i][j] = 0; //resets player target
  656. timeshitc++;
  657. cHit = 1;
  658. alreadyHit = 0;
  659. cAlreadyHit[i][j] = 1;
  660. }
  661. else if (cAlreadyHit[i][j] != 1) {
  662. cout << "Computer attacked at (" << j + 1 << ", " << i + 1 << ") and missed!." << endl;
  663. cHit = 0;
  664. alreadyHit = 0;
  665. cAlreadyHit[i][j] = 1;
  666. }
  667.  
  668. }
  669.  
  670. void hitPrinter(int x, int y, int player, int hit, int diff) {
  671. gotoxy(x * 2 + (player * 18) + player * (diff * 4), y);
  672. if (hit == 1) {
  673. cout << "X";
  674. }
  675. else {
  676. cout << "~";
  677. }
  678. gotoxy(0, 9);
  679. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement