#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <conio.h>
int main() {
std::vector<std::string> maze;
std::ifstream file("maze2.txt");
for (std::string line; std::getline(file, line);) {
maze.push_back(line); }
file.close();
int row = 1, column = 1;
int rowd = 2, columnd = 2;
while (true) {
std::vector<std::string> board = maze;
board[row][column] = '&';
/////////////////////////////////
for (std::string line: board) {
std::cout << line << std::endl; }
char key = getch();
std::system("cls");
switch (key) {
case 's': {
if (maze[row + 1][column] == ' ') {
++row; }
break; }
case 'w': {
if (maze[row - 1][column] == ' ') {
--row; }
break; }
case 'd': {
if (maze[row][column + 1] == ' ') {
++column; }
break; }
case 'a': {
if (maze[row][column - 1] == ' ') {
--column; }
break; }}
//////////////////////////
board[rowd][columnd] = '!';
for (std::string line: board) {
std::cout << line << std::endl; }
char keys = getch();
std::system("cls");
switch (keys) {
case 'k': {
if (maze[rowd + 1][columnd] == ' ') {
++rowd; }
break; }
case 'i': {
if (maze[rowd - 1][columnd] == ' ') {
--rowd; }
break; }
case 'l': {
if (maze[rowd][columnd + 1] == ' ') {
++columnd; }
break; }
case 'j': {
if (maze[rowd][columnd - 1] == ' ') {
--columnd; }
break; }}
}}