program line1(input, output); uses gralib; label 99; const frametime = 156; { time between frames, 60 cycle refresh } accel = 5; colorchange = 300; 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; debug: text; { debugger output file } 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; begin ;assign(debug, '_debug_out'); ;rewrite(debug); ;writeln(debug, 'Hello console from graphical window!'); rndseq := 1; { set random number generator inital to mid sequence } auto(output, false); curvis(output, false); x1 := maxxg(output) div 4+10; y1 := 1; lx1 := x1; ly1 := y1; xd1 := -1; yd1 := +1; x2 := maxxg(output)-(maxxg(output) div 4); y2 := maxyg(output); lx2 := x2; ly2 := y2; xd2 := -1; yd2 := -1; cc := 1; clr := color(rand mod 6+ord(red)); while true do begin for i := 1 to accel do begin fcolor(output, white); ;writeln(debug, 'line: x1: ', lx1:1, ' y1: ', ly1:1, ' x2: ', lx2:1, ' y2: ', ly2:1); line(output, lx1, ly1, lx2, ly2); lx1 := x1; ly1 := y1; lx2 := x2; ly2 := y2; 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; 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 end; wait end; 99: auto(output, true); curvis(output, true) end.