Computer Science Canada How to ensure shape doesn't go off screen? |
Author: | Luffy123 [ Fri May 25, 2012 9:56 pm ] |
Post subject: | How to ensure shape doesn't go off screen? |
So I have a shape from a class. Then I move the shape by 10 pixels at a time and erase it then redraw it. I have to ask the user to enter the distance to move the shape andd then it says to ensure it doesn't go off screen, So I did everything but now I just need a way to make sure it doesn't go off screen. How would I go about doing that? Is there already a method in turing that I can use? Or would I have to do something else. What would be the best possible way of doing this? Thank you! |
Author: | Amarylis [ Fri May 25, 2012 10:22 pm ] |
Post subject: | RE:How to ensure shape doesn\'t go off screen? |
Make it so that the new x/y coordinate can't be bigger than maxx/maxy - sizeOfShape |
Author: | blaffypoo [ Sat May 26, 2012 7:51 am ] |
Post subject: | RE:How to ensure shape doesn\'t go off screen? |
only move the shape if the right side of the shape is less than maxx and the left side is greater than 0 |
Author: | turinggirl [ Sun May 27, 2012 8:49 pm ] |
Post subject: | Re: How to ensure shape doesn't go off screen? |
Maxx-(image size) and maxy-(image size) ^now embed this in your program. |