This function checks the current mode in the mouseInputState variable and sets the desired orientation or position of the suit so that it renders correctly. Assume that the rotate mode has been set by left clicking in the main area of the applet window. The onPreRender function measures the horizontal distance across the window since the user first began to drag. It then compares this distance with the total width of the window. If the user has dragged across the entire width of the window, the suit will be rotated 360 degrees.
Smaller drags produce correspondingly smaller rotations.
For example, dragging half the width of the screen rotates the suit 180 degrees. The rotation process appears continuous because the suit s orientation is updated with each render cycle, as the onPreRender function is called with the most recent cursor locations. The same process applies to moving the suit by dragging with the right mouse button, except that the vertical drag distance is used. The default mode, and the left and right modes established by pressing the arrow buttons, are all essentially similar in that the suit rotates at a constant speed in each case. Here s where we get a good chance to understand the realtime frame rate concept discussed earlier.