Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

pascal matrix

a guest Nov 21st, 2018 77 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. Program Matrix;
  2. uses crt;
  3.  
  4. const x=80;
  5.       y=25;
  6.       speed=3;
  7.       a=20;
  8.       b=45;
  9.  
  10. type komorka=record
  11.                znak:byte;
  12.                kolor:boolean;
  13.              end;
  14.  
  15. var tablica:array[1..x,1..y] of komorka;
  16.     cykl:array[1..x] of byte;
  17.     dlugosc:array[1..x] of byte;
  18.     przerwa:array[1..x] of integer;
  19.     i,j,k:integer;
  20.  
  21. procedure przesun;
  22. begin
  23.   for i:=1 to x do
  24.     for k:=1 to cykl[i] do
  25.       begin
  26.         for j:=y downto 2 do
  27.           begin
  28.             tablica[i,j].znak:=tablica[i,j-1].znak;
  29.             tablica[i,j].kolor:=tablica[i,j-1].kolor;
  30.           end;
  31.         przerwa[i]:=przerwa[i]-1;
  32.         if przerwa[i]<=0 then
  33.           begin
  34.             tablica[i,1].znak:=random(94)+33;
  35.             if przerwa[i]=0 then tablica[i,1].kolor:=true else tablica[i,1].kolor:=false;
  36.             dlugosc[i]:=dlugosc[i]-1;
  37.             if dlugosc[i]<=0 then przerwa[i]:=random(b)+5;
  38.           end
  39.         else
  40.           begin
  41.             tablica[i,1].znak:=0;
  42.             dlugosc[i]:=random(a)+5;
  43.           end;
  44.       end;
  45. end;
  46.  
  47. procedure rysuj;
  48. begin
  49.   for i:=1 to x do
  50.     begin
  51.       for j:=1 to y do
  52.         begin
  53.           gotoxy(i,j);
  54.           if tablica[i,j].kolor=true then textcolor(lightgreen) else textcolor(green);
  55.           if tablica[i,j].znak=0 then write(' ') else write(chr(tablica[i,j].znak));
  56.         end;
  57.     end;
  58. end;
  59.  
  60. BEGIN
  61.   clrscr;
  62.   randomize;
  63.   for i:=1 to x do cykl[i]:=random(speed)+1;
  64.   for i:=1 to x do przerwa[i]:=random(b)+5;
  65.   repeat
  66.     przesun;
  67.     rysuj;
  68.   until keypressed;
  69.   delay(1000);
  70. end;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top