{******************************************************************************* Draws a moving tunnel *******************************************************************************} program tunnel3(input, output); uses gralib; label 99; const linespace = 40; var s: integer; cd: boolean; off: integer; xa, ya: integer; i: integer; procedure chkbrk; var er: evtrec; { event record } begin repeat event(input, er) until (er.etype = ettim) or (er.etype = etterm); if er.etype = etterm then goto 99 end; procedure drawrect(i: integer; x, y, sx, sy: integer); var hsx, hsy: integer; begin hsx := sx div 2; { find half rectangle } hsy := sy div 2; fcolorg(output, i, i, i); 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); timer(output, 1, 500, true); while true do begin for off := 0 to linespace-1 do begin select(output, ord(not cd)+1, ord(cd)+1); page(output); s := 1; while s < maxxg(output) do begin for i := 0 to linespace-1 do begin drawrect(maxint div linespace*i, maxxg(output) div 2, maxyg(output) div 2, s+off+xa, s+off+ya); s := s+1 end end; cd := not cd; { flip display and update surfaces } chkbrk; { wait frame and check for break } end end; 99: end.