Hey all, this is my first post so I apologize in advance if I mess up formatting. I am making a maze game with the player navigating to pick up a key and and use the key through a door to get to the exit. I am having trouble with making my walls work. My thought is to make an error statement for each movement direction.
char check_wall(game& myGame){
if('X' == myGame.maze[myGame.name.y][myGame.name.x+1]){
cout << "You hit a wall. " << endl;
return 1;
}
elseif('X' == myGame.maze[myGame.name.y][myGame.name.x-1]){
cout << "You hit a wall. " << endl;
return 1;
}
elseif('X' == myGame.maze[myGame.name.y-1][myGame.name.x]){
cout << "You hit a wall. " << endl;
return 1;
}
elseif('X' == myGame.maze[myGame.name.y+1][myGame.name.x]){
cout << "You hit a wall. " << endl;
return 1;
}
}
The if statements mostly work in main, except the return statements exit the program. Am I passing the function through incorrectly, or is it to do with the if statements? Thanks guys!