void findPath(void)
{
for (int i = 0; i<8; i++)
{
for (int j = 0; j <16; j++)
{
if (gameArray[i][j] == 'M')
{
if (positionCheck == false)
{
startX = j;
startY = i;
positionCheck = true;
cout << "Mouse is at: " << i << " " << j << endl;
}
}
}
}
// moving in north
if (gameArray[startY-1][startX] == ' ')
{
cout << "Replacing path!" << endl;
gameArray[startY-1][startX] = '+';
startY--;
findPath();
}
// moving in east
else if (gameArray[startY][startX+1] == ' ')
{
cout << "Replacing path!" << endl;
gameArray[startY][startX+1] = '+';
startX++;
findPath();
}
// backtracking
else if (gameArray[startY][startX] == '+')
{
cout << "Backtracking" << endl;
gameArray[startY][startX] = 'X';
if (moveEast == false)
{
startX--;
}
else if (moveNorth == false)
{
startY++;
}
findPath();
}
// checking for max north
else if (gameArray[startY-1][startX] == '*' && moveNorth == true)
{
moveNorth = false;
cout << "Max for north reached!" << endl;
gameArray[startY][startX] = 'X';
startY++;
findPath();
}
// checking for max east
else if (gameArray[startY][startX+1] == '*' && moveEast == true)
{
moveEast = false;
cout << "Max for east reached!" << endl;
gameArray[startY][startX] = 'X';
startX--;
findPath();
}
}