program line1(input, output); uses gralib; label 99; const frametime = 156; { time between frames, 60 cycle refresh } accel = 5; colorchange = 300; lag = 200; type linrec = record x1, y1, x2, y2: integer end; var x1, y1, xd1, yd1, i, x2, y2, xd2, yd2, lx1, ly1, lx2, ly2: integer; rndseq: integer; { random sequence seed } cc: integer; { color counter } clr: color; last: array[1..lag] of linrec; li: 1..lag; 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; 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; procedure putlast; var i: 1..lag; begin for i := 1 to lag-1 do last[i] := last[i+1]; last[lag].x1 := x1; last[lag].y1 := y1; last[lag].x2 := x2; last[lag].y2 := y2 end; begin rndseq := 1; { set random number generator inital to mid sequence } auto(output, false); curvis(output, false); x1 := maxxg(output) div 4+10; y1 := 1; xd1 := -1; yd1 := +1; x2 := maxxg(output)-(maxxg(output) div 4); y2 := maxyg(output); xd2 := -1; yd2 := -1; cc := 1; clr := color(rand mod 6+ord(red)); for li := 1 to lag do last[li].x1 := 0; while true do begin fcolor(output, white); if last[1].x1 > 0 then line(output, last[1].x1, last[1].y1, last[1].x2, last[1].y2); putlast; for i := 1 to accel do begin x1 := x1+xd1; y1 := y1+yd1; if (x1 = 1) or (x1 = maxxg(output)) then xd1 := -xd1; if (y1 = 1) or (y1 = maxyg(output)) then yd1 := -yd1; x2 := x2+xd2; y2 := y2+yd2; if (x2 = 1) or (x2 = maxxg(output)) then xd2 := -xd2; if (y2 = 1) or (y2 = maxyg(output)) then yd2 := -yd2; end; fcolor(output, clr); line(output, x1, y1, x2, y2); cc := cc+1; if cc >= colorchange then begin cc := 1; clr := color(rand mod 6+ord(red)) end; wait end; 99: auto(output, true); curvis(output, true) end.