For one of my programing classes I have to design a maze game, that has a character moving in a maze against time. The question is how to make it so that this character, in this case a button, can not pass through the maze line. I have decided to use retangles instead of lines for the maze, but I have no idea how to make it so the button cannot not move beyond the rectangle. I would like to have it so so if the buttons touches the inner boundrais of the rectangle it goes back to a starting position or stops. If anyone here has any good ideas please message me back.

Get the x and y coordinates of the button and the line/rectangle or whatever it cannot pass. Compare these x and y coordinates; do not move the button any further if it is at or past these coordinates.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.