Bounce.c
// Called by GLUT library when idle (window not being
// resized or moved)

Called by GLUT library when idle (window not being
resized or moved)
Called by GLUT library when idle ( window not being resized or moved )
void TimerFunction(int value)
        {
        if(x1 > windowWidth-rsize || x1 < 0)
                xstep = -xstep;
        if(y1 > windowHeight-rsize || y1 < 0)
                ystep = -ystep;
        if(x1 > windowWidth-rsize)
                x1 = windowWidth-rsize-1;
        if(y1 > windowHeight-rsize)
                y1 = windowHeight-rsize-1;
        x1 += xstep;
        y1 += ystep;
    glutPostRedisplay();
        glutTimerFunc(13,TimerFunction, 1);
        }
void TimerFunction ( int value ) { if ( x1 > windowWidth - rsize || x1 < 0 ) xstep = - xstep ; if ( y1 > windowHeight - rsize || y1 < 0 ) ystep = - ystep ; if ( x1 > windowWidth - rsize ) x1 = windowWidth - rsize - 1 ; if ( y1 > windowHeight - rsize ) y1 = windowHeight - rsize - 1 ; x1 += xstep ; y1 += ystep ; glutPostRedisplay ( ) ; glutTimerFunc ( 13 , TimerFunction , 1 ) ; }
Called by GLUT library when idle (window not being
resized or moved)
Called by GLUT library when idle ( window not being resized or moved )
// Reverse direction when you reach left or right edge
 // Reverse direction when you reach top or bottom edge
 // Check bounds.  This is incase the window is made
 // smaller and the rectangle is outside the new
 // clipping volume
 // Actually move the square
 // Redraw the scene with new coordinates
