Click Not working

My first post so im a newbie.
This is part of my main function (graphics program- Maze).

CreatMaze(maze), DrawWindow(maze, x, y), SolveMaze(maze), MoveRobot(maze, x, y, click), RestartMaze(maze) Are all functions that are correctly working (as far as I know)

None of them work i.e they do not respond to clicks except move robot. The rest do not work at all.


do
{
// get a mouse click
Point click = cwin.get_mouse("Click a button or move the robot");
// handle the different types of mouse clicks
if (click.get_x() >= 0 && click.get_x() <= 2 &&
click.get_y() >= -0.5 && click.get_y() <= -1.2 )
{
CreateMaze(maze);
x = 0;
y = 0;
}
// if (click.get_x() >= 4 && click.get_x() <= 6 &&
//click.get_y() >=-0.5 && click.get_y() <= -1.2 )
// {
//SolveMaze(maze);
// }
if (click.get_x() >= 8.5 && click.get_x() <= 10.5 &&
click.get_y() >=-0.5 && click.get_y() <= -1.2 )
{
RestartMaze(maze);
x = 0;
y = 0;
}
if (click.get_x() >= 13.5 && click.get_x() <= 16 &&
click.get_y() >=-0.5 && click.get_y() <= -1.2 )
{
exit = true;
}
// handle robot moves
if (click.get_x() >= 0 && click.get_x() <= 16 &&
click.get_y() >= 0 && click.get_y() <= 16)
{
MoveRobot(maze, x, y, click);
}
DrawWindow(maze, x, y);
} while (!exit);
{

return 0;
}
}
closed account (D80DSL3A)
click.get_y() >=-0.5 && click.get_y() <= -1.2

Those conditions cannot be met.
Those co-ordinates are on the window though?
closed account (D80DSL3A)
No value for click.get_y() can satisfy the 2 conditions. There are no numbers which are >= -0.5 and <= -1.2 That is the problem.
It is mathematically impossible.

ie. your conditions are written incorrectly.
The robot move works because the condition:
click.get_y() >= 0 && click.get_y() <= 16
can be met by any number from 0 to 16
Last edited on
Solved it thanks!
That was the problem. Instead of changing the whole co-ordinate structure I just did one y-axis condition click.get_y() <0 , with the same x-axis conditions.

Thanks a lot!
Topic archived. No new replies allowed.