For this assignment we have to demonstrate the idea of motion. My goal was to create a box and have a ball bounce around in the box. I began with the box. I set up a box the was connected to the position of the mouse. Instead of using the regular rectangle where the position is the upper left corner, I changed the mode to center and set the coordinates to the x and y position of the mouse. This will allow the box to follow the mouse when it is moved. The next step was to create a circle. I created a circle and gave it a velocity. After I accomplished that, I had to restrict the ball to the box. Using “if statements”, I created boundaries defined by the edges of the square and changed the balls velocity from positive to negative, to simulate the ball bouncing off the sides of the box. When the box is moved, the ball will remain moving only in the box.
There still are some problems with my code. If you move the mouse too fast the ball will be left behind and out of the box. Once you move the box back over the circle it will begin to move again.