asmodeus94

Bomberman - tp7

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