asmodeus94

Bomberman - fp

Jan 27th, 2012
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 20.82 KB | None | 0 0
  1. program bOOmberman;
  2. uses crt,dos;
  3. var
  4. tab : array [1..29,1..18] of char;
  5. tabBombWybuch : array [3..27,2..17] of longint;
  6. tabBombPoWybuchu : array [3..27,2..17] of longint;
  7. tabRuchPotwor : array [3..27,2..17] of longint;
  8. wzorMap : array [1..25,1..16] of char;
  9. tabPoziom : array [1..10,1..25,1..16] of char;
  10. idziesz,idbomby,menu,odPauzuj{blokPauzy} : char;
  11. i,j,bomby,ileBomb,potwory,bylPotwor,ostByloPotwo,ostByloBomb,mozliwychBomb,jestAleZginal,
  12. zycia,dodamZycie,czyZyje,instrwlwyl,poziom,menuWybor,menuWybor2,menuWybor3,menuWybor4,
  13. trudnosc,blokPauzy : byte;
  14. Hour,Min,Sec,HSec : word;
  15. czas : longint;
  16. label koniec,restart,poczatek,powrotDoMenu,pauza,wznowGre,
  17.       gora,dol,lewo,prawo;
  18. {lvl do wypelniania tablicy tabPoziom[lvl,*,*], poziom to konkretna mapka}
  19. procedure wyswietl(wyswco:byte);
  20. var x,y:byte;
  21. begin
  22. if wyswco=0 then begin
  23. for x:=3 to 27 do begin
  24.     for y:=2 to 17 do begin
  25.     gotoxy(10+x,2+y);
  26.     write(tab[x,y]);
  27.     end;end;end;
  28. if wyswco=1 then begin
  29. for x:=1 to 25 do begin
  30.     for y:=1 to 16 do begin
  31.     if x<>25 then tab[x+2,y+1]:=tabPoziom[poziom,x,y];
  32.     gotoxy(10+x+2,2+y+1);
  33.     write(tab[x+2,y+1]);
  34.     end;end;end;
  35. if wyswco=3 then begin
  36. for x:=1 to 25 do begin
  37.     for y:=1 to 16 do begin
  38.     gotoxy(10+x+2,2+y+1);
  39.     if (tab[x+2,y+1]<>('˛'))AND(tab[x+2,y+1]<>#176) then begin
  40.     tab[x+2,y+1]:=#176;
  41.     write(tab[x+2,y+1]);end;
  42.     end;end;end;
  43. end;
  44. procedure sciana;
  45. var x,y : byte;
  46. begin
  47. for x:=1 to 29 do begin
  48.     for y:=1 to 18 do begin
  49.     if (x=1)OR(x=2)OR(x=28)OR(x=29)OR(y=1)OR(y=18) then tab[x,y]:=('˛');
  50.     gotoxy(10+x,2+y);write(tab[x,y]);
  51.     end;
  52. end;end;
  53. procedure polozenieRestart;
  54. begin
  55. REPEAT
  56. i:=random(28);
  57. j:=random(18);UNTIL tab[i,j]=#176;
  58. gotoxy(10+i,2+j);tab[i,j]:=#4;write(tab[i,j]);gotoxy(1,1);
  59. end;
  60. {*** wzor do generatora map ***}
  61. procedure mapWzor;
  62. var x,y : byte;
  63. begin
  64. for x:=1 to 25 do begin
  65.     for y:=1 to 16 do begin
  66.     wzorMap[x,y]:=#176;
  67.     end;end;{mozna modyfikowac jak sie chce}
  68. wzorMap[2,2]:=('˛');wzorMap[3,2]:=('˛');wzorMap[4,2]:=('˛');wzorMap[3,3]:=('˛');
  69. wzorMap[8,3]:=('˛');wzorMap[9,3]:=('˛');
  70. wzorMap[12,2]:=('˛');wzorMap[12,3]:=('˛');
  71. wzorMap[19,2]:=('˛');wzorMap[19,3]:=('˛');
  72. wzorMap[22,2]:=('˛');wzorMap[22,3]:=('˛');wzorMap[23,2]:=('˛');wzorMap[23,3]:=('˛');wzorMap[24,2]:=('˛');wzorMap[24,3]:=('˛');
  73. {koniec 1.}
  74. wzorMap[3,6]:=('˛');wzorMap[3,7]:=('˛');wzorMap[4,7]:=('˛');
  75. wzorMap[7,7]:=('˛');wzorMap[8,7]:=('˛');wzorMap[9,7]:=('˛');
  76. wzorMap[13,6]:=('˛');wzorMap[13,7]:=('˛');
  77. wzorMap[17,6]:=('˛');wzorMap[18,6]:=('˛');wzorMap[19,6]:=('˛');
  78. wzorMap[23,6]:=('˛');wzorMap[23,7]:=('˛');wzorMap[24,6]:=('˛');wzorMap[24,7]:=('˛');{koniec 2.}
  79. wzorMap[2,11]:=('˛');wzorMap[3,11]:=('˛');wzorMap[3,10]:=('˛');wzorMap[4,11]:=('˛');
  80. wzorMap[7,10]:=('˛');wzorMap[8,10]:=('˛');
  81. wzorMap[12,10]:=('˛');wzorMap[12,11]:=('˛');wzorMap[13,11]:=('˛');
  82. wzorMap[17,10]:=('˛');wzorMap[17,11]:=('˛');wzorMap[18,10]:=('˛');wzorMap[18,11]:=('˛');
  83. wzorMap[22,10]:=('˛');wzorMap[22,11]:=('˛');wzorMap[23,10]:=('˛');wzorMap[23,11]:=('˛');{koniec 3.}
  84. wzorMap[3,14]:=('˛');wzorMap[3,15]:=('˛');wzorMap[4,14]:=('˛');
  85. wzorMap[7,14]:=('˛');wzorMap[7,15]:=('˛');wzorMap[8,14]:=('˛');wzorMap[8,15]:=('˛');wzorMap[9,14]:=('˛');wzorMap[9,15]:=('˛');
  86. wzorMap[12,15]:=('˛');wzorMap[13,15]:=('˛');
  87. wzorMap[17,15]:=('˛');wzorMap[18,15]:=('˛');wzorMap[19,15]:=('˛');
  88. wzorMap[23,14]:=('˛');wzorMap[24,14]:=('˛');{koniec 4.}
  89. end;
  90. procedure mapGenerator;
  91. var a,b,c,d,e,s,t,x,y,liczbakostek,lvl : byte;
  92. begin
  93. REPEAT
  94. lvl:=lvl+1;a:=1;b:=5;c:=1;e:=4;liczbakostek:=0;
  95. REPEAT
  96. d:=random(20)+1;
  97.    if d=1 then begin s:=1;t:=1;end;if d=2 then begin s:=6;t:=1;end;
  98.    if d=3 then begin s:=11;t:=1;end;if d=4 then begin s:=16;t:=1;end;if d=5 then begin s:=21;t:=1;end;
  99.    if d=6 then begin s:=1;t:=5;end;if d=7 then begin s:=6;t:=5;end;
  100.    if d=8 then begin s:=11;t:=5;end;if d=9 then begin s:=16;t:=5;end;if d=10 then begin s:=21;t:=5;end;
  101.    if d=11 then begin s:=1;t:=9;end;if d=12 then begin s:=6;t:=9;end;
  102.    if d=13 then begin s:=11;t:=9;end;if d=14 then begin s:=16;t:=9;end;if d=15 then begin s:=21;t:=9;end;
  103.    if d=16 then begin s:=1;t:=13;end;if d=17 then begin s:=6;t:=13;end;
  104.    if d=18 then begin s:=11;t:=13;end;if d=19 then begin s:=16;t:=13;end;if d=20 then begin s:=21;t:=13;end;
  105.  for x:=a to b do begin
  106.     for y:=c to e do begin
  107.     tabPoziom[lvl,x,y]:=wzorMap[s,t];
  108.     t:=t+1;
  109.     end;
  110.     s:=s+1;
  111. end;
  112. if b=25 then begin c:=c+4;e:=e+4;a:=1;b:=5 end ELSE a:=a+5;b:=b+5;
  113. liczbakostek:=liczbakostek+1;
  114. UNTIL liczbakostek=20;
  115. UNTIL lvl=10;
  116. gotoxy(18,21);write('                                     ');
  117. end;
  118. procedure fbombki;
  119. begin
  120. idbomby:=('ţ');
  121. if (tab[i,j]<>idbomby)AND(bomby>0) then begin
  122.    bomby:=bomby-1;tab[i,j]:=idbomby;
  123.    tabBombWybuch[i,j]:=czas+3;
  124.    end;
  125. end;
  126. procedure sprawdzBomby;
  127. var x,y : byte;
  128. begin
  129. ileBomb:=0;
  130. for x:=3 to 27 do begin
  131.     for y:=2 to 17 do begin
  132.     if tab[x,y]=idbomby then ileBomb:=ileBomb+1;
  133.     end;
  134. end;
  135. end;
  136. procedure sprawdzBohatera;
  137. var x,y,licznik : byte;
  138. begin
  139. czyZyje:=0;
  140. licznik:=0;
  141. REPEAT
  142. for x:=3 to 27 do begin
  143.     for y:=2 to 17 do begin
  144.     if tab[x,y]=#4 then czyZyje:=1;
  145.     end;
  146. end;
  147. licznik:=licznik+1;
  148. UNTIL licznik=3;
  149. end;
  150. procedure tabGoraBomby;
  151. begin
  152. gotoxy(16,1);write('                                             ');
  153. gotoxy(16,1);
  154. write('Pozostalo ',bomby,' bomb');end;
  155. procedure tabGoraPotwory;
  156. begin
  157. gotoxy(16,2);write('                 ');
  158. gotoxy(20,2);
  159. write('Potworow: ',potwory);end;
  160. procedure tabPrawaZycia;
  161. begin
  162. gotoxy(53,3);write('               ');
  163. gotoxy(53,3);
  164. write('Zycia: ',zycia);end;
  165. procedure ktoryPoziom;
  166. begin
  167. gotoxy(21,21);write('             ');gotoxy(21,21);write('Poziom ',poziom,'.');
  168. end;
  169. procedure bombaMiga;
  170. var x,y:byte;
  171. begin
  172. for x:=3 to 27 do begin
  173.     for y:=2 to 17 do begin
  174.     if tab[x,y]=('ţ') then begin
  175.     gotoxy(10+x,2+y);
  176.     textcolor(7+blink);
  177.     write(tab[x,y]);end;textcolor(7);end;
  178. end;gotoxy(1,1);end;
  179. procedure wybuch;
  180. var m,n,p,x,y,a,b :  byte;
  181. begin
  182. for m:=3 to 27 do begin
  183.     for n:=2 to 17 do begin
  184.     if tab[m,n]=idbomby then begin
  185.         if tabBombWybuch[m,n]<=czas then begin
  186.         tab[m,n]:=#15;gotoxy(10+m,2+n);tabBombWybuch[m,n]:=0;write(tab[m,n]);
  187.         a:=m+2;
  188.         b:=n+2;
  189.         for x:=m-2 to a do tabBombPoWybuchu[x,n]:=czas+2;
  190.         for y:=n-2 to b do tabBombPoWybuchu[m,y]:=czas+2;
  191.         p:=0;REPEAT  p:=p+1;if tab[m+p,n]=idbomby then begin tabBombWybuch[m+p,n]:=0;
  192.         wybuch;end;
  193.         if tab[m+p,n]<>('˛') then begin tab[m+p,n]:=#15;gotoxy(10+m+p,2+n);write(tab[m+p,n]);end;
  194.         UNTIL (p=2)OR(tab[m+p,n]=('˛'));
  195.         p:=0;REPEAT  p:=p+1;if tab[m-p,n]=idbomby then begin tabBombWybuch[m-p,n]:=0;
  196.         wybuch;end;
  197.         if tab[m-p,n]<>('˛') then begin tab[m-p,n]:=#15;gotoxy(10+m-p,2+n);write(tab[m-p,n]);end;
  198.         UNTIL (p=2)OR(tab[m-p,n]=('˛'));
  199.         p:=0;REPEAT  p:=p+1;if tab[m,n-p]=idbomby then begin tabBombWybuch[m,n-p]:=0;
  200.         wybuch;end;
  201.         if tab[m,n-p]<>('˛') then begin tab[m,n-p]:=#15;gotoxy(10+m,2+n-p);write(tab[m,n-p]);end;
  202.         UNTIL (p=2)OR(tab[m,n-p]=('˛'));
  203.         p:=0;REPEAT  p:=p+1;if tab[m,n+p]=idbomby then begin tabBombWybuch[m,n+p]:=0;
  204.         wybuch;end;
  205.         if tab[m,n+p]<>('˛') then begin tab[m,n+p]:=#15;gotoxy(10+m,2+n+p);write(tab[m,n+p]);end;
  206.         UNTIL (p=2)OR(tab[m,n+p]=('˛'));
  207.         end;
  208.     end;
  209.     end;
  210. end;
  211. end;
  212. procedure sprzatajWybuch;
  213. var x,y : byte;
  214. begin
  215. for x:=3 to 27 do begin
  216.     for y:=2 to 17 do begin
  217.     if tab[x,y]=#15 then begin
  218.        if tabBombPoWybuchu[x,y]<=czas then begin
  219.        tab[x,y]:=#176;gotoxy(10+x,2+y);write(tab[x,y]);
  220.        end;
  221.     end;
  222.     end;
  223. end;
  224. sprawdzBohatera;
  225. end;
  226. procedure genPotwory(potwory:byte);
  227. var x,y,u,p,r,s,licznik,mozeByc : byte;
  228. begin licznik:=0;mozeByc:=0;
  229. if (potwory>0)AND(potwory<11) then begin
  230. REPEAT
  231.    REPEAT
  232.    x:=random(25)+1;
  233.    y:=random(16)+1;
  234.    p:=x+1;
  235.    s:=y+1;
  236.    if (tab[x,y]<>('˛'))AND(tab[x,y]<>#4)AND(tab[x,y]<>#2) then mozeByc:=1;
  237.    for u:=x-1 to p do begin
  238.        for r:=y-1 to s do begin
  239.        if (tab[u,r]=#4)OR(tab[u,r]=#2) then mozeByc:=0;
  240.        end;
  241.    end;
  242.    UNTIL (x>2)AND(x<26)AND(y>1)AND(y<17)AND(mozeByc=1);
  243. tab[x,y]:=#2;gotoxy(10+x,y+2);write(tab[x,y]);
  244. mozeByc:=0;
  245. licznik:=licznik+1;
  246. UNTIL licznik=potwory;end;end;
  247. procedure sprawdzPotwory;
  248. var x,y : byte;
  249. begin
  250. potwory:=0;
  251. for x:=3 to 27 do begin
  252.     for y:=2 to 17 do begin
  253.     if tab[x,y]=#2 then potwory:=potwory+1;
  254.     end;
  255. end;
  256. end;
  257. procedure ruchPotwora;
  258. var x,y,gdzieIsc,moze,niemoze,pionPozi : byte;
  259. begin
  260. for x:=3 to 27 do begin
  261.     for y:=2 to 17 do begin
  262.     if tab[x,y]=#2 then begin
  263.        if tabRuchPotwor[x,y]<=czas then begin
  264.        niemoze:=0;
  265.        REPEAT
  266.        gdzieIsc:=random(8)+1;
  267.        if gdzieIsc>4 then gdzieIsc:=5;
  268.        moze:=0;
  269.           case gdzieIsc of
  270.           1: begin gora:
  271.           if tab[x,y-1]=#15 then begin tab[x,y]:=#176;gotoxy(x+10,y+2);write(tab[x,y]);moze:=1;end ELSE begin
  272.           if (tab[x,y-1]<>#178)AND(y>1)AND(tab[x,y-1]<>#2)AND(tab[x,y-1]<>idbomby) then begin
  273.           if tab[x,y-1]=#4 then begin jestAleZginal:=1;end;
  274.           tab[x,y-1]:=#2;gotoxy(x+10,y+2-1);write(tab[x,y-1]);gotoxy(x+10,y+2);tab[x,y]:=#176;write(tab[x,y]);
  275.           tabRuchPotwor[x,y]:=0;tabRuchPotwor[x,y-1]:=czas+trudnosc;moze:=1;end ELSE begin moze:=0;niemoze:=niemoze+1;end;
  276.           end;
  277.           end;
  278.           2: begin dol: if tab[x,y+1]=#15 then begin tab[x,y]:=#176;gotoxy(x+10,y+2);write(tab[x,y]);moze:=1;end ELSE begin
  279.           if (tab[x,y+1]<>#178)AND(y<17)AND(tab[x,y+1]<>#2)AND(tab[x,y+1]<>idbomby) then begin
  280.           if tab[x,y+1]=#4 then begin jestAleZginal:=1;end;
  281.           tab[x,y+1]:=#2;gotoxy(x+10,y+2+1);write(tab[x,y+1]);gotoxy(x+10,y+2);tab[x,y]:=#176;write(tab[x,y]);
  282.           tabRuchPotwor[x,y]:=0;tabRuchPotwor[x,y+1]:=czas+trudnosc;moze:=1;end ELSE begin moze:=0;niemoze:=niemoze+1;end;
  283.           end;
  284.           end;
  285.           3: begin lewo:
  286.           if tab[x-1,y]=#15 then begin tab[x,y]:=#176;gotoxy(x+10,y+2);write(tab[x,y]);moze:=1;end ELSE begin
  287.           if (tab[x-1,y]<>#178)AND(x>2)AND(tab[x-1,y]<>idbomby)AND(tab[x-1,y]<>#2) then begin
  288.           if tab[x-1,y]=#4 then begin jestAleZginal:=1;end;
  289.           tab[x-1,y]:=#2;gotoxy(x+10-1,y+2);write(tab[x-1,y]);gotoxy(x+10,y+2);tab[x,y]:=#176;write(tab[x,y]);
  290.           tabRuchPotwor[x,y]:=0;tabRuchPotwor[x-1,y]:=czas+trudnosc;moze:=1;end ELSE begin moze:=0;niemoze:=niemoze+1;end;
  291.           end;
  292.           end;
  293.           4: begin prawo:
  294.           if tab[x+1,y]=#15 then begin tab[x,y]:=#176;gotoxy(x+10,y+2);write(tab[x,y]);moze:=1;end ELSE begin
  295.           if (tab[x+1,y]<>#178)AND(x<28)AND(tab[x+1,y]<>#2)AND(tab[x+1,y]<>idbomby) then begin
  296.           if tab[x+1,y]=#4 then begin jestAleZginal:=1;end;
  297.           tab[x+1,y]:=#2;gotoxy(x+10+1,y+2);write(tab[x+1,y]);gotoxy(x+10,y+2);tab[x,y]:=#176;write(tab[x,y]);
  298.           tabRuchPotwor[x,y]:=0;tabRuchPotwor[x+1,y]:=czas+trudnosc;moze:=1;end ELSE begin moze:=0;niemoze:=niemoze+1;end;
  299.           end;
  300.           end;
  301.           5: begin
  302.           pionPozi:=random(2);
  303.              if pionPozi=0 then begin
  304.                 if y>j then goto gora ELSE goto dol
  305.  
  306.              end ELSE begin
  307.                 if x>i then goto lewo ELSE goto prawo;
  308.                       end;
  309.           end;
  310.           end;
  311.        UNTIL (moze=1)OR(niemoze=4);
  312.        end;
  313.     end;
  314.     end;
  315. end;
  316. end;
  317. procedure potworyZaczekajcie;
  318. var x,y : byte;
  319. begin
  320. for x:=3 to 27 do begin
  321.     for y:=2 to 17 do begin
  322.     tabRuchPotwor[x,y]:=czas+2*trudnosc;
  323.     end;
  324. end;
  325. end;
  326. procedure jakiPoziomTrudnosci;
  327. var tekst : string;
  328. begin
  329. gotoxy(3,22);write('Poziom trudnosci:');
  330. if trudnosc=3 then begin tekst:='LATWY';textcolor(yellow);end;
  331. if trudnosc=2 then begin tekst:='SREDNI';textcolor(brown);end;
  332. if trudnosc=1 then begin tekst:='TRUDNY';textcolor(red);end;
  333. gotoxy(21,22);write(tekst);textcolor(7);
  334. end;
  335. procedure instrukcja(pozInstr:byte);
  336. var a,b:byte;
  337. begin
  338. instrwlwyl:=instrwlwyl+1;
  339. if instrwlwyl=1 then begin textcolor(green);
  340. gotoxy(pozInstr,8);write('w - ruch w gore');      {42}
  341. gotoxy(pozInstr,9);write('s - ruch w dol');
  342. gotoxy(pozInstr,10);write('a - ruch w lewo');
  343. gotoxy(pozInstr,11);write('d - ruch w prawo');
  344. gotoxy(pozInstr,12);write('enter - podloz bombe');
  345. gotoxy(pozInstr,13);write('r - restart');
  346. gotoxy(pozInstr,14);write('l - skakanie miedzy poziomami');
  347. gotoxy(pozInstr,15);write('p - pauza (kolejne nacisniecie wznawia)');
  348. gotoxy(pozInstr,16);write('m - powrot do menu');
  349. gotoxy(pozInstr,17);write('z - wylacz gre');textcolor(red);
  350. gotoxy(pozInstr,18);write('Bomby mozna zbierac (przed wybuchem)!');textcolor(7);
  351. end;
  352. if instrwlwyl=2 then begin
  353. for a:=0 to 40 do begin
  354.     for b:=1 to 20 do begin
  355.     gotoxy(a+40,4+b);write(' ');
  356.     end;
  357. end;instrwlwyl:=0;end;end;
  358. procedure pokazMenu(ktoreMenu:byte);
  359. var a,posprzatajPoziomy:byte;
  360. begin
  361. REPEAT
  362. gotoxy(1,1);
  363. case ktoreMenu of
  364. 1: begin
  365. writeln('B O M B E R M A N');
  366. menu:=readkey;
  367. if (menu='w')OR(menu='W') then begin
  368. if menuWybor<4 then menuWybor:=menuWybor+1;end;
  369. if (menu='s')OR(menu='S') then begin
  370. if menuWybor>1 then menuWybor:=menuWybor-1;end;
  371. case menuWybor of
  372. 4: begin textcolor(red);writeln('   NOWA GRA');textcolor(7);
  373. writeln('POZIOM TRUDNOSCI   ');writeln('INSTRUKCJA   ');writeln('WYJDZ   ');end;
  374. 3: begin writeln('NOWA GRA   ');textcolor(red);
  375. writeln('   POZIOM TRUDNOSCI');textcolor(7);writeln('INSTRUKCJA   ');writeln('WYJDZ   ');end;
  376. 2: begin writeln('NOWA GRA   ');writeln('POZIOM TRUDNOSCI   ');
  377. textcolor(red);writeln('   INSTRUKCJA');textcolor(7);writeln('WYJDZ   ');end;
  378. 1: begin writeln('NOWA GRA   ');writeln('POZIOM TRUDNOSCI   ');
  379. writeln('INSTRUKCJA   ');textcolor(red);writeln('   WYJDZ');textcolor(7);end;
  380. end;end;
  381. 2: begin
  382. textcolor(green);writeln('POZIOM TRUDNOSCI');textcolor(7);
  383. menu:=readkey;
  384. if (menu='w')OR(menu='W') then begin
  385. if menuWybor2<4 then menuWybor2:=menuWybor2+1;end;
  386. if (menu='s')OR(menu='S') then begin
  387. if menuWybor2>1 then menuWybor2:=menuWybor2-1;end;
  388. case menuWybor2 of
  389. 4: begin textcolor(red);writeln('   LATWY');textcolor(7);writeln('SREDNI   ');writeln('TRUDNY   ');writeln('MENU   ');end;
  390. 3: begin writeln('LATWY   ');textcolor(red);writeln('   SREDNI');textcolor(7);writeln('TRUDNY   ');writeln('MENU   ');end;
  391. 2: begin writeln('LATWY   ');writeln('SREDNI   ');textcolor(red);writeln('   TRUDNY');textcolor(7);writeln('MENU   ');end;
  392. 1: begin writeln('LATWY   ');writeln('SREDNI   ');writeln('TRUDNY   ');textcolor(red);writeln('   MENU');textcolor(7);end;
  393. end;end;
  394. 3: begin
  395. textcolor(green);writeln('Czy chcesz zagrac jeszcze raz?');textcolor(7);
  396. menu:=readkey;
  397. if (menu='w')OR(menu='W') then begin
  398. if menuWybor3<2 then menuWybor3:=menuWybor3+1;end;
  399. if (menu='s')OR(menu='S') then begin
  400. if menuWybor3>1 then menuWybor3:=menuWybor3-1;end;
  401. case menuWybor3 of
  402. 2: begin textcolor(red);writeln('   TAK');textcolor(7);writeln('NIE   ');end;
  403. 1: begin textcolor(7);writeln('TAK   ');textcolor(red);writeln('   NIE');textcolor(7);end;
  404. end;end;
  405. 4: begin
  406. posprzatajPoziomy:=1;
  407. menu:=readkey;
  408. gotoxy(1,2);
  409. if (menu='s')OR(menu='S') then begin
  410. if menuWybor4<10 then menuWybor4:=menuWybor4+1;end;
  411. if (menu='w')OR(menu='W') then begin
  412. if menuWybor4>1 then menuWybor4:=menuWybor4-1;end;
  413. for a:=1 to 10 do begin
  414.     if menuWybor4 = a then begin
  415.     textcolor(red);writeln(a);textcolor(7);poziom:=menuWybor4;
  416.     end ELSE begin writeln(a);end;
  417. end;gotoxy(1,1);end;
  418. end;
  419. UNTIL menu=#13;
  420. if posprzatajPoziomy=1 then begin
  421.    for a:=1 to 10 do begin
  422.    gotoxy(1,a+1);write('  ');
  423.    end;
  424. posprzatajPoziomy:=0;
  425. end;
  426. end;
  427. procedure wyswietlWyborPoziomu;
  428. var a : byte;
  429. begin
  430. menuWybor4:=poziom;gotoxy(1,2);
  431. for a:=1 to 10 do begin
  432.     if menuWybor4 <> a then
  433.     writeln(a) ELSE begin textcolor(red);writeln(a);textcolor(7); end;
  434. end;
  435. end;
  436. procedure ruch(i,j:byte);
  437. begin
  438. if tab[i,j]=('ţ') then begin
  439. bomby:=bomby+1;end;
  440. if (tab[i,j]=#2)OR(tab[i,j]=#15) then begin
  441. bylPotwor:=1;
  442. end ELSE bylPotwor:=0;
  443. tab[i,j]:=#4;
  444. gotoxy(10+i,2+j);write(tab[i,j]);
  445. end;
  446. procedure Timer;
  447. begin
  448. REPEAT
  449. GetTime(Hour,Min,Sec,Hsec);czas:=3600*hour+60*Min+Sec;
  450. wybuch;sprzatajWybuch;sprawdzBomby;ruchPotwora;bombaMiga;
  451. UNTIL keypressed;
  452. end;
  453. {* Cialo programu *}
  454. begin trudnosc:=2;poczatek:instrwlwyl:=0;{aby nie naciskac po dedzie (przez 2)}clrscr;randomize;
  455. REPEAT powrotDoMenu:clrscr;menuWybor:=4;
  456. gotoxy(1,1);writeln('B O M B E R M A N');
  457. textcolor(red);writeln('   NOWA GRA');textcolor(7);writeln('POZIOM TRUDNOSCI');writeln('INSTRUKCJA');write('WYJDZ');
  458. pokazMenu(1); if menuWybor=1 then goto koniec;clrscr;
  459. if menuWybor=3 then begin
  460. clrscr;menuWybor2:=4;
  461. textcolor(green);writeln('POZIOM TRUDNOSCI');textcolor(7);
  462. textcolor(red);writeln('   LATWY');textcolor(7);writeln('SREDNI');writeln('TRUDNY');writeln('MENU');
  463. pokazMenu(2);
  464. if menuWybor2=4 then begin trudnosc:=3;goto powrotDoMenu;end;
  465. if menuWybor2=3 then begin trudnosc:=2;goto powrotDoMenu;end;
  466. if menuWybor2=2 then begin trudnosc:=1;goto powrotDoMenu;end;
  467. if menuWybor2=1 then goto powrotDoMenu;
  468. end;
  469. if menuWybor=2 then begin instrukcja(22);instrwlwyl:=0;
  470. gotoxy(22,2);textbackground(white);textcolor(blue);write('Autorem gry jest Radoslaw Adamowicz');textcolor(7);
  471. textbackground(black);
  472. textcolor(red);gotoxy(22,19);write('Instrukcja dostepna po nacisniciu');
  473. gotoxy(22,19);write('klawisza k');textcolor(7);gotoxy(1,1);
  474. readkey;goto powrotDoMenu;end;
  475. clrscr;
  476. textcolor(red);gotoxy(53,2);writeln('Instrukcja - k');textcolor(7);
  477. {config}
  478. zycia:=5;
  479. bomby:=20;
  480. poziom:=1;
  481. mozliwychBomb:=3;{w jednym momencie mozna polozyc tyle bomb}{config_}
  482. tabPrawaZycia;
  483. ostByloBomb:=bomby;tabGoraBomby;
  484. gotoxy(18,21);write('Prosze czekac');textcolor(7+blink);write('...');textcolor(7);
  485. sciana;wyswietl(0);mapWzor;mapGenerator;ktoryPoziom;wyswietl(1);wyswietl(3);
  486. polozenieRestart;genPotwory(poziom);sprawdzPotwory;ostByloPotwo:=potwory;tabGoraPotwory;
  487. ktoryPoziom;jakiPoziomTrudnosci;
  488. dodamZycie:=0;{jezeli przejde 3 poziomy, dostaje zycie}
  489. REPEAT
  490. wznowGre:
  491. Timer;
  492. if jestAleZginal=1 then ileBomb:=0;{jezeli zgine, ale przedtem poloze bombe}
  493. if (czyZyje=0)AND(ileBomb=0) then begin zycia:=zycia-1;dodamZycie:=0;jestAleZginal:=0;goto restart;end;
  494. {(flaga)jezeli mnie nie widac i wybuchly bomby}
  495. jestAleZginal:=0;czyZyje:=1;
  496. if blokPauzy=1 then begin pauza: REPEAT odPauzuj:=readkey UNTIL (odPauzuj='p')OR(odPauzuj='P');gotoxy(1,1);
  497. textcolor(green);write('GRA WZNOWIONA');textcolor(7);potworyZaczekajcie;gotoxy(1,1);write('             ');
  498. gotoxy(1,1);goto wznowGre;end;
  499. idziesz:=readkey;
  500. case idziesz of
  501. 'w','W': begin if tab[i,j-1]<>('˛') then begin gotoxy(10+i,2+j);
  502. if tab[i,j]<>idbomby then begin tab[i,j]:=#176;write(tab[i,j]);end;ruch(i,j-1);j:=j-1;end;end;
  503. 's','S': begin if tab[i,j+1]<>('˛') then begin gotoxy(10+i,2+j);
  504. if tab[i,j]<>idbomby then begin tab[i,j]:=#176;write(tab[i,j]);end;ruch(i,j+1);j:=j+1;end;end;
  505. 'a','A': begin if tab[i-1,j]<>('˛') then begin gotoxy(10+i,2+j);
  506. if tab[i,j]<>idbomby then begin tab[i,j]:=#176;write(tab[i,j]);end;ruch(i-1,j);i:=i-1;end;end;
  507. 'd','D': begin if tab[i+1,j]<>('˛') then begin gotoxy(10+i,2+j);
  508. if tab[i,j]<>idbomby then begin tab[i,j]:=#176;write(tab[i,j]);end;ruch(i+1,j);i:=i+1;end;end;
  509. #13: begin if (bomby=0)AND(ileBomb=0) then goto restart; if ileBomb<mozliwychBomb then fbombki;end;
  510. 'k','K': begin instrukcja(42);end;{klawiszologia}
  511. 'l','L': begin wyswietlWyborPoziomu;pokazMenu(4);
  512. wyswietl(1);wyswietl(3);bomby:=20;polozenieRestart;genPotwory(poziom);ktoryPoziom;end;
  513. 'p','P': begin gotoxy(1,1);textcolor(red);write('PAUZA');textcolor(7);goto pauza;end;
  514. 'm','M': begin goto poczatek;end;
  515. 'r','R': begin goto restart;end;
  516. end;
  517. {jezeli wpadlem na potwora, wtedy restart (flaga)}
  518. if bylPotwor=1 then begin zycia:=zycia-1;goto restart;end;{koniec flagi}
  519. if (czyZyje=0)AND(ileBomb=0) then begin zycia:=zycia-1;dodamZycie:=0;goto restart;end;{(flaga)jezeli 0 to znaczy ze nie zyje}
  520. sprawdzPotwory;
  521. if (potwory=0) then begin dodamZycie:=dodamZycie+1;if dodamZycie mod 3=0 then zycia:=zycia+1;poziom:=poziom+1;sciana;restart:
  522. wyswietl(1);wyswietl(3);polozenieRestart;genPotwory(poziom);sprawdzPotwory;tabGoraPotwory;ktoryPoziom;
  523. bomby:=20;tabPrawaZycia;end;
  524. if zycia=0 then begin
  525. clrscr;menuWybor3:=2;
  526. textcolor(red);textcolor(green);writeln('Czy chcesz zagrac jeszcze raz?');textcolor(red);writeln('   TAK');textcolor(7);
  527. writeln('NIE');delay(1000);pokazMenu(3);
  528. if menuWybor3=2 then goto poczatek ELSE idziesz:='z';
  529. end;{funkcje sprawdzajace, czy zmienila sie ilosc bomb (dostepnych), potworow na mapie}
  530. if ostByloPotwo<>potwory then begin tabGoraPotwory;ostByloPotwo:=potwory;end;
  531. if ostByloBomb<>bomby then begin tabGoraBomby;ostByloBomb:=bomby;end;
  532. UNTIL (idziesz='z')OR(idziesz='Z')OR(poziom>10);
  533. clrscr;
  534. if poziom>10 then begin gotoxy(1,1);write('Gratuluje, przeszedles cala gre!');
  535. readkey;delay(3000);goto poczatek;end;
  536. UNTIL (idziesz='z')OR(idziesz='Z')OR(poziom>10);
  537. koniec:clrscr;write('Koniec gry');delay(2000);
  538. end.
Advertisement
Add Comment
Please, Sign In to add comment