{******************************************************************************* Draws a moving tunnel *******************************************************************************} program tunnel1(input, output); uses gralib; label 99; const linespace = 20; var s: integer; cd: boolean; off: integer; xa, ya: integer; procedure chkbrk; var er: evtrec; { event record } begin repeat event(input, er) until (er.etype = etframe) or (er.etype = etterm); if er.etype = etterm then goto 99 end; procedure drawrect(c: color; x, y, sx, sy: integer); var hsx, hsy: integer; begin hsx := sx div 2; { find half rectangle } hsy := sy div 2; fcolor(output, c); rect(output, x-hsx, y-hsy, x+hsx, y+hsy) end; begin curvis(output, false); cd := false; xa := 0; ya := 0; if maxxg(output) > maxyg(output) then { adjust aspect } xa := maxxg(output)-maxyg(output) else ya := maxyg(output)-maxxg(output); frame(output, true); while true do begin for off := 0 to linespace-1 do begin select(output, ord(not cd)+1, ord(cd)+1); page(output); linewidth(output, 3); s := 1; while s < maxxg(output) do begin drawrect(black, maxxg(output) div 2, maxyg(output) div 2, s+off+xa, s+off+ya); s := s+linespace end; cd := not cd; { flip display and update surfaces } chkbrk; { wait frame and check for break } end end; 99: end.