const C_OF_B := 12
 
const C_OF_B2 := 12
 
const NUMOFBALLS := 1000
 
const PROX := 11
 
const EX_SIZE := 400
 
const SIZE := 3
 
const M_S := 20
 
const MIDX := maxx div 2
 
const MIDY := maxy div 2
 
var Xm, Ym, Click : int
 
const SPEED := 9
 
var Length : array 1 .. NUMOFBALLS of real4
 
var X : array 1 .. NUMOFBALLS of int
 
var Dx : array 1 .. NUMOFBALLS of int
 
var Y : array 1 .. NUMOFBALLS of int
 
var Dy : array 1 .. NUMOFBALLS of int
 
var C : array 1 .. NUMOFBALLS of int
 
var SX : array 1 .. NUMOFBALLS of int
 
var SY : array 1 .. NUMOFBALLS of int
 
process Clear
 
    loop
 
        delay (500)
 
        cls
 
    end loop
 
end Clear
 
setscreen ("graphics:max,max,nobuttonbar,offscreenonly,nocursor")
 
for Index : 1 .. NUMOFBALLS
 
    Y (Index) := 1
 
    X (Index) := 1
 
    randint (C (Index), 1, 15)
 
end for
 
 
colorback (7)
 
cls
 
%fork Clear
 
loop
 
    cls
 
    mousewhere (Xm, Ym, Click)
 
    for Index : 1 .. NUMOFBALLS
 
 
        Length (Index) := sqrt ((X (Index) - Xm) ** 2 + (Y (Index) - Ym) ** 2)
 
        SX (Index) := X (Index) - Xm
 
        SY (Index) := Y (Index) - Ym
 
 
    end for
 
 
    if Click = 0 then
 
        for Index : 1 .. NUMOFBALLS
 
            if Length (Index) > PROX then
 
                Dx (Index) := SX (Index) div (Length (Index) div SPEED)
 
                Dy (Index) := SY (Index) div (Length (Index) div SPEED)
 
            end if
 
        end for
 
    else
 
 
        for Index : 1 .. NUMOFBALLS
 
            if Length (Index) > PROX then
 
                Dx (Index) := 0
 
                Dy (Index) := 0
 
                Dx (Index) := - (SX (Index) div (Length (Index) div SPEED))
 
                Dy (Index) := - (SY (Index) div (Length (Index) div SPEED))
 
            end if
 
        end for
 
 
    end if
 
 
 
    %  drawfilloval (Xm, Ym, M_S, M_S, C_OF_B2)
 
    for Index : 1 .. NUMOFBALLS
 
 
        X (Index) := X (Index) + (Dx (Index))
 
        Y (Index) := Y (Index) + (Dy (Index))
 
 
        if /*Length (Index) > EX_SIZE then */ X (Index) > maxx + 200 or X (Index) < -200 or
 
                Y (Index) > maxy + 200 or Y (Index) < -200 then
 
            loop
 
                randint (X (Index), Xm - 40, Xm + 40)
 
                randint (Y (Index), Ym - 40, Ym + 40)
 
                Length (Index) := sqrt ((X (Index) - Xm) ** 2 + (Y (Index) - Ym) ** 2)
 
                exit when Length (Index) > 4
 
            end loop
 
 
        end if
 
        %drawline (X (Index), Y (Index), Xm, Ym, C_OF_B)
 
        %drawoval (Xm, Ym, EX_SIZE, EX_SIZE, C_OF_B2)
 
        if Click = 1 then
 
            drawfilloval (Xm, Ym, 2, 2, 12)
 
        end if
 
        drawfilloval (X (Index), Y (Index), SIZE, SIZE, C (Index))
 
        % drawfilloval (X (Index), Y (Index), SIZE, SIZE, C_OF_B)
 
    end for
 
    exit when hasch
 
    View.Update
 
end loop
 
  |