Field.cpp 820 B

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