1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
void generateMaze(string maze[13][13]) {
int sCell[2];
getStarterCell(sCell);
bool loop = true;
int cCell[2] = {sCell[0], sCell[1]};
int backable = 0;
while (loop) { // gotta loop!
string nDir = newD(maze, sCell); //the new direction
int nexCell[2]; //the next cell
if (nDir == "None") { //backtrack start
nDir = backD(maze, sCell);
if (nDir == "None") {
cout << "Error, Backtracking issue! Backable: " << backable;
break;
}
else {
backable--;
nexCell[0] = {getNX(maze, cCell[0], nDir, 2) };
nexCell[1] = {getNY(maze, cCell[1], nDir, 2) };
}
}
else { //normal procedures
backable++;
nexCell[0] = {getNX(maze, cCell[0], nDir, 2)};
nexCell[1] = {getNY(maze, cCell[1], nDir, 2)};
}
destWall(maze, cCell[0], cCell[1], nDir);
cCell[0] = nexCell[0];
cCell[1] = nexCell[1];
if (backable <= 0) {
cout << "Maze (should be) finished!";
loop = false;
break;
}
}
}
|