Field.cpp 977 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <iostream>
  2. #include "Const.h"
  3. #include "Field.h"
  4. //Ñîçäàíèå ïóñòîãî èãðîâîãî ïîëÿ
  5. void init_field(char (*field)[columns])
  6. {
  7. for (int i = 0; i < columns; i++)
  8. {
  9. field[0][i] = field[rows - 1][i] = '*';
  10. }
  11. for (int j = 1; j < rows - 1; j++)
  12. {
  13. field[j][0] = field[j][columns - 1] = '*';//óñòàíîâêà ãðàíèö
  14. }
  15. clear_field(field);
  16. }
  17. //Ìàññèâ èãðîâîãî ïîëÿ çàïîëíÿåòñÿ ñèìâîëîì-çàïîëíèòåëåì.
  18. void clear_field(char (* field)[columns])
  19. {
  20. for (int i = 1; i < rows - 1; i++)//çàïîëíåíèå ïîëÿ ïóñòûìè ñèìâîëàìè
  21. {
  22. for (int j = 1; j < columns - 1; j++)
  23. {
  24. field[i][j] = field_symbol;
  25. }
  26. }
  27. }
  28. //Ìàññèâ èãðîâîãî ïîëÿ âûâîäèòñÿ íà ýêðàí.
  29. void print_field(char(* field)[columns], int& score)//Ìàññèâ èãðîâîãî ïîëÿ âûâîäèòñÿ íà ýêðàí.
  30. {
  31. for (int i = 0; i < rows; i++)//çàïîëíåíèå ïîëÿ ïóñòûìè ñèìâîëàìè
  32. {
  33. for (int j = 0; j < columns; j++)
  34. {
  35. std::cout << field[i][j];
  36. }
  37. std::cout << std::endl;
  38. }
  39. std::cout << "Score: " << score << std::endl;
  40. }