12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- #include <iostream>
- #include "Const.h"
- #include "Field.h"
- //Ñîçäàíèå ïóñòîãî èãðîâîãî ïîëÿ
- void init_field(char (*field)[columns])
- {
- for (int i = 0; i < columns; i++)
- {
- field[0][i] = field[rows - 1][i] = '*';
- }
- for (int j = 1; j < rows - 1; j++)
- {
- field[j][0] = field[j][columns - 1] = '*';//óñòàíîâêà ãðàíèö
- }
-
- clear_field(field);
- }
- //Ìàññèâ èãðîâîãî ïîëÿ çàïîëíÿåòñÿ ñèìâîëîì-çàïîëíèòåëåì.
- void clear_field(char (* field)[columns])
- {
- for (int i = 1; i < rows - 1; i++)//çàïîëíåíèå ïîëÿ ïóñòûìè ñèìâîëàìè
- {
- for (int j = 1; j < columns - 1; j++)
- {
- field[i][j] = field_symbol;
- }
- }
- }
- //Ìàññèâ èãðîâîãî ïîëÿ âûâîäèòñÿ íà ýêðàí.
- void print_field(char(* field)[columns], int& score)//Ìàññèâ èãðîâîãî ïîëÿ âûâîäèòñÿ íà ýêðàí.
- {
- for (int i = 0; i < rows; i++)//çàïîëíåíèå ïîëÿ ïóñòûìè ñèìâîëàìè
- {
- for (int j = 0; j < columns; j++)
- {
- std::cout << field[i][j];
- }
- std::cout << std::endl;
- }
- std::cout << "Score: " << score << std::endl;
- }
|