process OUTPUT
''
'' COPYRIGHT (C) 1993, CACI Products Company.
'' AUTHOR: Steve Bailey
'' DATE: 9-22-93
'' DESCRIPTION:
''     The purpose of this process is to do animation for the entire simulation.
''     All bouncing balls are drawn at their X and Y locations.  The floor
''     is redisplayed if it is being pushed down on.
''

define BALL, LOWEST.BALL as a pointer variable

'' wait for other processes to start
wait MIN.STEP.V units

'' initialize
call INITIALIZE.OUTPUT

'' display all balls in the simulation
while SIMULATION.DONE eq .FALSE do
    if BALL.SET not empty
        '' find the lowest of the bouncing balls
        for each BALL in BALL.SET, 
            compute LOWEST.BALL as the minimum(BALL) of Y(BALL)
    
        '' display the floor appropriately pushed down by the lowest ball
        if Y(LOWEST.BALL) lt .FLOOR.POS
            display FLOOR at (LOCATION.X(FLOOR), Y(LOWEST.BALL))
        always
    
        '' display all bouncing balls
        for each BALL in BALL.SET
            display BALL at (X(BALL), Y(BALL))
    always

    work MAX.STEP.V units
loop

End
