{******************************************************************************* Place random balls *******************************************************************************} program ball3(input, output); uses gralib; label 99; const ballsize = 51; halfball = ballsize div 2; frametime = 156; { time between frames, 60 cycle refresh } var rndseq: integer; { random sequence seed } procedure wait; var er: evtrec; { event record } begin timer(input, 1, frametime, false); repeat event(input, er) until (er.etype = ettim) or (er.etype = etterm); if er.etype = etterm then goto 99 end; procedure drawball(c: color; x, y: integer); begin fcolor(output, c); { set color } fellipse(output, x-halfball+1, y-halfball+1, x+halfball-1, y+halfball-1) end; function rand: integer; const a = 16807; m = 2147483647; var gamma: integer; begin gamma := a*(rndseq mod (m div a))-(m mod a)*(rndseq div (m div a)); if gamma > 0 then rndseq := gamma else rndseq := gamma+m; rand := rndseq end; begin auto(output, false); curvis(output, false); rndseq := 1; { set random number generator inital to mid sequence } while true do begin drawball(color(rand mod 6+ord(red)), rand mod (maxxg(output)-ballsize)+halfball, rand mod (maxyg(output)-ballsize)+halfball); wait end; 99: auto(output, true); curvis(output, true) end.