Logic Error- Maze not displaying
Jan 24, 2014 at 3:41am UTC
Hey everyone:
So I have a program where I solve a maze using stacks. So my display_maze function take two parameters and displays the maze according to where the x coordinate and y coordinate are.
I have an error during my move function, as my maze doesn't display for some reason
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 37 38 39 40 41 42 43 44 45 46 47
void Player::player_move()
{
Stack stack;
Maze maze;
Lock taken;
// Monster monster;
stack.push_values();
while (x_coordinate != 11 || y_coordinate != 2){
char top = stack.peek();
top = stack.peek();
stack.pop();
if (top == 'U' && maze.maze[y_coordinate - 1][x_coordinate] == 0)
{
y_coordinate -= 1;
stack.move(top);
}
else if (top == 'D' && maze.maze[y_coordinate+ 1][x_coordinate] == 0)
{
y_coordinate += 1;
stack.move(top);
}
else if (top == 'R' && maze.maze[y_coordinate][x_coordinate + 1] == 0)
{
x_coordinate += 1;
stack.move(top);
}
else if (top == 'L' && maze.maze[y_coordinate][x_coordinate-=1] == 0)
{
x_coordinate -= 1;
stack.move(top);
}
if (x_coordinate == taken.x_coordinate && y_coordinate == taken.y_coordinate)
{
taken.set_posession(true );
}
system("cls" );
maze.display_maze(x_coordinate, y_coordinate);
Sleep(200);
}
}
It should be displaying, because after debugging I discovered the problem isn't with the display_maze function.
Thanks for the help!
Jan 24, 2014 at 4:27am UTC
"My car won't start! Here's the exhaust pipe."
We need more than you have shown us.
Topic archived. No new replies allowed.