def getshift(point point )new utility function '''returns tuple (dxdywhich is the shift from point to point ''dx point getx(point getx(dy point gety(point gety(return (dxdysince the function calculates both change in and yit returns tuple straightforward interactive methodgetusershiftis wrapped around this function to get the user' choicewhich ultimately returns the same tupledef getusershift(pointpromptwin)#new direction selection '''return the change in position from the point to mouse click in win first display the prompt string under point ''text text(point(point getx() )prompttext draw(winuserpt win getmouse(text undraw(return getshift(pointuserptin the new version of the main driverbounceballexcerpted belowthis interactive setting of (dxdyis used note the multiple assignment statement to both dx and dyset from the tuple returned from getusershift this shift would generally be much too much for single animation stepso the actual values passed to bounceball are scaled way down by factor scale center point(win getwidth()/ win getheight()/ #new central starting point ball makedisk(centerradiuswin#new interactive direction and speed setting prompt ''click to indicate the direction and speed of the ballthe further you click from the ballthe faster it starts ''(dxdygetusershift(centerpromptwinscale to reduce the size of animation steps bounceinbox(balldx*scaledy*scalexlowxhighylowyhighwinthe bounceinbox method has the same change to the loop as in the randomcircles py example the method then requires the graphwinwinas further parametersince checkmouse is graphwin method you can look in idle at the full source code for bounce py if you like the changes from bounce py are all marked with comment starting with #newand all the major changes have been described above in the examples so far of the use of checkmouse()we have only used the fact that point was clickednot which point the next example versionbounce pydoes use the location of mouse clicks that are read with checkmouse(to change the direction and speed of the ball try it this version only slightly modifies the central animation functionbounceinboxbut wraps it in another looping function that makes the direction and speed of the ball change on each mouse click hence the mouse clicks detected in bounceinbox need to be remembered and then returned after the main animation loop finishes that requires nameptto be given to the last mouse clickso it can be remembered this means modifying the main animation loop to initialize the variable pt before the loop and reset it at the end of the loopmuch as in the use of getmouse(for the interactive polygon creation that explains the first three new lines and the last two new lines in the revised bounceinboxdef bounceinbox(shapedxdyxlowxhighylowyhighwin)''animate shape moving in jumps (dxdy)bouncing when while statements