Making walls for a c++ maze game

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
char check_wall(game& myGame){
	
if('X' == myGame.maze[myGame.name.y][myGame.name.x+1]){
	cout << "You hit a wall. " << endl;
	return 1;
	}
	
else if('X' == myGame.maze[myGame.name.y][myGame.name.x-1]){
	cout << "You hit a wall. " << endl;
	return 1;
	}
else if('X' == myGame.maze[myGame.name.y-1][myGame.name.x]){
	cout << "You hit a wall. " << endl;
	return 1;
	}
else if('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!
Topic archived. No new replies allowed.