Advertisement
Coriic

STATKI 05.01 12.00

Jan 5th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.51 KB | None | 0 0
  1. program statki;
  2.  
  3. uses allegro, crt, dos;
  4.  
  5. type
  6. tablica=ARRAY[-1..11,-1..11] of integer;
  7.  
  8. const
  9. ScreenWidth= 1200;
  10. ScreenHeight= 720;
  11.  
  12. var
  13. tab1, tab2, tab1_c, tab2_c : tablica;
  14. litery : ARRAY [1..20] of string;
  15. mx, my, mb, tryb, komp, _1, _2, typ : integer;
  16.  
  17. procedure inicjalizuj();
  18. var
  19. i, j: integer;
  20. begin
  21. al_init;
  22. al_install_keyboard;
  23. al_install_mouse;
  24. al_set_color_depth(32);
  25. al_set_gfx_mode(Al_GFX_AUTODETECT_WINDOWED,ScreenWidth,ScreenHeight,0,0);
  26. al_show_mouse( al_screen );
  27. al_unscare_mouse();
  28. for i:=0 to 11 do
  29. begin
  30. for j:=0 to 11 do
  31. begin
  32. tab1[i][j]:=0;
  33. tab2[i][j]:=0;
  34. tab1_c[i][j]:=0;
  35. tab2_c[i][j]:=0;
  36. end;
  37. end;
  38. litery[1]:='A';
  39. litery[2]:='B';
  40. litery[3]:='C';
  41. litery[4]:='D';
  42. litery[5]:='E';
  43. litery[6]:='F';
  44. litery[7]:='G';
  45. litery[8]:='H';
  46. litery[9]:='I';
  47. litery[10]:='J';
  48. litery[11]:='1';
  49. litery[12]:='2';
  50. litery[13]:='3';
  51. litery[14]:='4';
  52. litery[15]:='5';
  53. litery[16]:='6';
  54. litery[17]:='7';
  55. litery[18]:='8';
  56. litery[19]:='9';
  57. litery[20]:='10';
  58. komp:=0;
  59. end;
  60.  
  61. procedure pozycja_myszki();
  62. begin
  63. if ((mx <> al_mouse_x) AND (my <> al_mouse_y) AND (mb <> al_mouse_b)) then
  64. begin
  65. mx:=al_mouse_x;
  66. my:=al_mouse_y;
  67. mb:=al_mouse_b;
  68. end;
  69. end;
  70.  
  71. procedure clear ();
  72. begin
  73. al_clear_to_color( al_screen, al_makecol( 0, 0, 0 ) );
  74. end;
  75.  
  76. procedure wyswietl_c (var tab : tablica; var tab_c :tablica);
  77. var
  78. i, j : integer;
  79. begin
  80. for i:=1 to 10 do
  81. begin
  82. for j:=1 to 10 do
  83. begin
  84. if (tab[i][j]>0) then
  85. begin
  86. al_rectfill( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 30, 30 ) );
  87. al_rect( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 30, 30 ) );
  88. end;
  89. if (tab[i][j]=-1) then
  90. begin
  91. al_rectfill( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 0, 0, 0 ) );
  92. al_rect( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 200, 200 ) );
  93. end;
  94. if ((tab[i][j]=-10) OR (tab[i][j]=-11) OR (tab[i][j]=-9)) then
  95. begin
  96. al_rectfill( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 0, 0, 0 ) );
  97. al_rect( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 200, 200 ) );
  98. al_line( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 200, 200 ) );
  99. al_line( al_screen, (j-1)*30+435, (i-1)*30+90, j*30+430, i*30+35, al_makecol( 200, 200, 200 ) );
  100. end;
  101. end;
  102. end;
  103. for i:=1 to 10 do
  104. begin
  105. for j:=1 to 10 do
  106. begin
  107. if (tab_c[i][j]=-1) then
  108. begin
  109. al_rectfill( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 0, 0, 0 ) );
  110. al_rect( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 200, 200, 200 ) );
  111. end;
  112. if (tab_c[i][j]=-2) then
  113. begin
  114. al_rectfill( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 200, 200, 200 ) );
  115. al_rect( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 200, 200, 200 ) );
  116. end;
  117. if (tab_c[i][j]=-3) then
  118. begin
  119. al_rectfill( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 255, 255, 0 ) );
  120. al_rect( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 200, 200, 200 ) );
  121. end;
  122. end;
  123. end;
  124. end;
  125.  
  126. procedure wyswietl (var tab : tablica; var tab_c:tablica; gracz : string; parametr : integer);
  127. var
  128. i, j : integer;
  129. begin
  130. al_textout_ex(al_screen, al_font,gracz, 350, 10, al_makecol(200,200,200), -1);
  131. for i:=1 to 10 do
  132. begin
  133. for j:=1 to 10 do
  134. begin
  135. if (tab_c[i][j]=0) then
  136. begin
  137. al_rectfill( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 128, 30, 30 ) );
  138. al_rect( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 128, 30, 30 ) );
  139. end;
  140. if (tab_c[i][j]=-1) then
  141. begin
  142. al_rectfill( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 0, 0, 0 ) );
  143. al_rect( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 200, 200, 200 ) );
  144. end;
  145. if (tab_c[i][j]=-2) then
  146. begin
  147. al_rectfill( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 200, 200, 200 ) );
  148. al_rect( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 200, 200, 200 ) );
  149. end;
  150. if (tab_c[i][j]=-3) then
  151. begin
  152. al_rectfill( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 255, 255, 0 ) );
  153. al_rect( al_screen, (j-1)*30+35, (i-1)*30+65, j*30+30, i*30+60, al_makecol( 200, 200, 200 ) );
  154. end;
  155. end;
  156. end;
  157. for i:=1 to 10 do
  158. begin
  159. for j:=1 to 10 do
  160. begin
  161. if (tab[i][j]=0) then
  162. begin
  163. al_rectfill( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 128, 30, 30 ) );
  164. al_rect( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 128, 30, 30 ) );
  165. end;
  166. if (tab[i][j]>0) then
  167. begin
  168. al_rectfill( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 30, 30 ) );
  169. al_rect( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 30, 30 ) );
  170. end;
  171. if (tab[i][j]=-1) then
  172. begin
  173. al_rectfill( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 0, 0, 0 ) );
  174. al_rect( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 200, 200 ) );
  175. end;
  176. if ((tab[i][j]=-10) OR (tab[i][j]=-11) OR (tab[i][j]=-9)) then
  177. begin
  178. al_rectfill( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 0, 0, 0 ) );
  179. al_rect( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 200, 200 ) );
  180. al_line( al_screen, (j-1)*30+435, (i-1)*30+65, j*30+430, i*30+60, al_makecol( 200, 200, 200 ) );
  181. al_line( al_screen, (j-1)*30+435, (i-1)*30+90, j*30+430, i*30+35, al_makecol( 200, 200, 200 ) );
  182. end;
  183. end;
  184. end;
  185. al_textout_ex(al_screen, al_font,'Twoje statki', 540, 30, al_makecol(200,200,200), -1);
  186. al_textout_ex(al_screen, al_font,'Twoje strzaly', 130, 30, al_makecol(200,200,200), -1);
  187. for i:=1 to 10 do
  188. begin
  189. al_textout_ex(al_screen, al_font,litery[i], (i-1)*30+44, 50, al_makecol(200,200,200), -1);
  190. al_textout_ex(al_screen, al_font,litery[i], (i-1)*30+444, 50, al_makecol(200,200,200), -1);
  191. end;
  192. for i:=11 to 20 do
  193. begin
  194. al_textout_ex(al_screen, al_font, litery[i], 15, (i-11)*30+73, al_makecol(200,200,200), -1);
  195. al_textout_ex(al_screen, al_font, litery[i], 415, (i-11)*30+73, al_makecol(200,200,200), -1);
  196. end;
  197. if (parametr>=-1) then
  198. begin
  199. al_textout_ex(al_screen, al_font,'Stworz:', 750, 50, al_makecol(200,200,200), -1);
  200. al_textout_ex(al_screen, al_font,'1x czteromasztowiec', 750, 70, al_makecol(200,200,200), -1);
  201. al_textout_ex(al_screen, al_font,'2x trojmasztowiec', 750, 90, al_makecol(200,200,200), -1);
  202. al_textout_ex(al_screen, al_font,'3x dwumasztowiec', 750, 110, al_makecol(200,200,200), -1);
  203. al_textout_ex(al_screen, al_font,'4x jednomasztowiec', 750, 130, al_makecol(200,200,200), -1);
  204. end;
  205. if (parametr>=0) then
  206. begin
  207. al_line( al_screen, 750, (parametr*20)+75, 900, (parametr*20)+75, al_makecol( 200, 200, 200 ) );
  208. end;
  209. if (parametr=-2) then
  210. begin
  211. al_textout_ex(al_screen, al_font,'Legenda:', 750, 70, al_makecol(200,200,200), -1);
  212. al_rectfill( al_screen, 750, 90 , 780, 120, al_makecol( 0, 0, 0 ) );
  213. al_rect( al_screen, 750, 90, 780, 120, al_makecol( 200, 200, 200 ) );
  214. al_textout_ex(al_screen, al_font,'-pudlo', 790, 105, al_makecol(200,200,200), -1);
  215. al_rectfill( al_screen, 750, 130 , 780, 160, al_makecol( 200, 200, 200 ) );
  216. al_rect( al_screen, 750, 130, 780, 160, al_makecol( 200, 200, 200 ) );
  217. al_textout_ex(al_screen, al_font,'-trafiony, niezatopiony', 790, 145, al_makecol(200,200,200), -1);
  218. al_rectfill( al_screen, 750, 170 , 780, 200, al_makecol( 255, 255 , 0 ) );
  219. al_rect( al_screen, 750, 170, 780, 200, al_makecol( 200, 200, 200 ) );
  220. al_textout_ex(al_screen, al_font,'-trafiony, zatopiony', 790, 185, al_makecol(200,200,200), -1);
  221. al_rectfill( al_screen, 750, 210 , 780, 240, al_makecol( 200, 30 , 30 ) );
  222. al_rect( al_screen, 750, 210, 780, 240, al_makecol( 200, 200, 200 ) );
  223. al_textout_ex(al_screen, al_font,'-twoj statek', 790, 225, al_makecol(200,200,200), -1);
  224. al_rectfill( al_screen, 750, 250, 780, 280, al_makecol( 0, 0, 0 ) );
  225. al_rect( al_screen, 750, 250, 780, 280, al_makecol( 200, 200, 200 ) );
  226. al_line( al_screen, 750, 250, 780, 280, al_makecol( 200, 200, 200 ) );
  227. al_line( al_screen, 750, 280, 780, 250, al_makecol( 200, 200, 200 ) );
  228. al_textout_ex(al_screen, al_font,'-strzaly przeciwnika', 790, 265, al_makecol(200,200,200), -1);
  229. end;
  230. al_rectfill( al_screen, 10, 660 , 100, 710, al_makecol( 0, 0, 0 ) );
  231. al_rect( al_screen, 10, 660, 100, 710, al_makecol( 200, 200, 200 ) );
  232. al_textout_ex(al_screen, al_font,'Wyjdz', 35, 685, al_makecol(200,200,200), -1);
  233. end;
  234.  
  235. function warunek_tworzenia_1(var tab : tablica; d : integer) : boolean;
  236. begin
  237. if (((tab[((my-65)DIV 30)+2][((mx-435)DIV 30)]=d) OR (tab[((my-65)DIV 30)+2][((mx-435)DIV 30)]=0)) AND ((tab[((my-65)DIV 30)+2][((mx-435)DIV 30)+1]=d) OR (tab[((my-65)DIV 30)+2][((mx-435)DIV 30)+1]=0)) AND ((tab[((my-65)DIV 30)+2][((mx-435)DIV 30)+2]=d) OR (tab[((my-65)DIV 30)+2][((mx-435)DIV 30)+2]=0)) AND ((tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+2]=d) OR (tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+2]=0)) AND ((tab[((my-65)DIV 30)+1][((mx-435)DIV 30)]=d) OR (tab[((my-65)DIV 30)+1][((mx-435)DIV 30)]=0)) AND ((tab[((my-65)DIV 30)][((mx-435)DIV 30)]=d) OR (tab[((my-65)DIV 30)][((mx-435)DIV 30)]=0)) AND ((tab[((my-65)DIV 30)][((mx-435)DIV 30)+1]=d) OR (tab[((my-65)DIV 30)][((mx-435)DIV 30)+1]=0)) AND ((tab[((my-65)DIV 30)][((mx-435)DIV 30)+2]=d)OR (tab[((my-65)DIV 30)][((mx-435)DIV 30)+2]=0))AND (tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]=0))then
  238. warunek_tworzenia_1:=true
  239. else
  240. warunek_tworzenia_1:=false;
  241. end;
  242.  
  243. function warunek_tworzenia_2 (var tab:tablica; i : integer) : boolean;
  244. begin
  245. if (((tab[((my-65)DIV 30)+2][((mx-435)DIV 30)+1]=i) OR (tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+2]=i) OR (tab[((my-65)DIV 30)+1][((mx-435)DIV 30)]=i) OR (tab[((my-65)DIV 30)][((mx-435)DIV 30)+1]=i))AND (tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]=0)) then
  246. warunek_tworzenia_2:=true
  247. else
  248. warunek_tworzenia_2:=false;
  249. end;
  250.  
  251. procedure koniec(wygrany : string);
  252. begin
  253. al_textout_centre_ex(al_screen,al_font,'KONIEC GRY', ScreenWidth div 2, ScreenHeight div 3, al_makecol(200,200,200), -1);
  254. al_textout_centre_ex(al_screen,al_font,'Wygral:', ScreenWidth div 2-30, ScreenHeight div 3+15, al_makecol(200,200,200), -1);
  255. al_textout_centre_ex(al_screen,al_font,wygrany, (ScreenWidth div 2)+42, ScreenHeight div 3+15, al_makecol(200,200,200), -1);
  256. al_readkey;
  257. halt;
  258. end;
  259.  
  260. function przekroczenie_1( a: integer; b: integer; c: integer; d: integer):boolean;
  261. begin
  262. if ((mb=1) AND (((mx<a) OR (mx>b)) OR ((my<c) OR (my>d)))) then
  263. begin
  264. al_textout_ex(al_screen, al_font, 'Jestes poza plansza', 310, 450, al_makecol(200,200,200), -1);
  265. przekroczenie_1 :=true;
  266. if ((mx>10) AND (mx<100) AND(my>660) AND (my<710)) then
  267. begin
  268. al_rectfill( al_screen, 10, 660 , 100, 710, al_makecol( 200, 200, 200 ) );
  269. al_rect( al_screen, 10, 660, 100, 710, al_makecol( 200, 200, 200 ) );
  270. al_textout_ex(al_screen, al_font,'Wyjdz', 35, 685, al_makecol(0,0,0), -1);
  271. delay(500);
  272. clear();
  273. koniec('pies');
  274. end;
  275. end
  276. else
  277. begin
  278. al_textout_ex(al_screen, al_font, 'Jestes poza plansza', 310, 450, al_makecol(0,0,0), -1);
  279. przekroczenie_1:=false;
  280. end;
  281. end;
  282.  
  283. procedure tworzenie_4(var tab : tablica;var tab_c :tablica; gracz : string);
  284. var
  285. m : integer;
  286. begin
  287. m:=0;
  288. al_textout_ex(al_screen, al_font, 'Stworz 4 masztowiec', 310, 400, al_makecol(200,200,200), -1);
  289. wyswietl(tab,tab_c, gracz, -1);
  290. repeat
  291. begin
  292. mb:=0;
  293. repeat
  294. pozycja_myszki();
  295. przekroczenie_1(435,750,65,360);
  296. until ((mb=1)AND (przekroczenie_1(435,750,65,360)=false));
  297. if (m=0) then
  298. begin
  299. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=10;
  300. m:=m+1;
  301. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  302. end
  303. else
  304. begin
  305. if (warunek_tworzenia_2(tab, 10)=true) then
  306. begin
  307. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=10;
  308. m:=m+1;
  309. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  310. end
  311. else if (warunek_tworzenia_2(tab, 10)=false) then
  312. begin
  313. al_textout_ex(al_screen, al_font, 'Statek musi byc polaczony', 250, 420, al_makecol(200,200,200), -1);
  314. end;
  315. end;
  316. end;
  317. wyswietl_c(tab, tab_c);
  318. until (m=4);
  319. wyswietl_c(tab, tab_c);
  320. end;
  321.  
  322. procedure tworzenie_3(var tab: tablica; var tab_c :tablica; gracz : string);
  323. var
  324. m, d, p : integer;
  325. begin
  326. al_textout_ex(al_screen, al_font, 'Stworz 4 masztowiec', 310, 400, al_makecol(0,0,0), -1);
  327. for d:=8 to 9 do
  328. begin
  329. wyswietl(tab,tab_c, gracz,0);
  330. m:=0;
  331. al_textout_ex(al_screen, al_font, 'Stworz 3 masztowiec', 310, 400, al_makecol(200,200,200), -1);
  332. wyswietl_c(tab, tab_c);
  333. repeat
  334. begin
  335. mb:=0;
  336. repeat
  337. pozycja_myszki();
  338. przekroczenie_1(435,750,65,360);
  339. until ((mb=1) AND (przekroczenie_1(435,750,65,360)=false));
  340. if (warunek_tworzenia_1(tab, d)=true) then
  341. begin
  342. if (m>=1) then
  343. begin
  344. if (warunek_tworzenia_2(tab,d)=true) then
  345. begin
  346. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=d;
  347. m:=m+1;
  348. p:=1;
  349. end
  350. else
  351. begin
  352. al_textout_ex(al_screen, al_font, 'Statek musi byc polaczony', 250, 420, al_makecol(200,200,200), -1);
  353. end;
  354. end
  355. else
  356. begin
  357. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=d;
  358. m:=m+1;
  359. p:=1;
  360. end;
  361. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  362. end
  363. else if(warunek_tworzenia_1(tab, d)=false) then
  364. begin
  365. al_textout_ex(al_screen, al_font, 'Nowo utworzony statek nie moze dotykac statku wczesniej utworzonego', 310, 420, al_makecol(200,200,200), -1);
  366. p:=1;
  367. end;
  368. if(p=0) then
  369. begin
  370. if (warunek_tworzenia_2(tab, d)=true) then
  371. begin
  372. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=d;
  373. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  374. m:=m+1;
  375. end
  376. else if(warunek_tworzenia_2(tab, d)=false) then
  377. begin
  378. al_textout_ex(al_screen, al_font, 'Statek musi byc polaczony', 250, 420, al_makecol(200,200,200), -1);
  379.  
  380. end;
  381. end;
  382. wyswietl_c(tab,tab_c);
  383. end;
  384. p:=0;
  385. until (m=3);
  386. wyswietl_c(tab,tab_c);
  387. end;
  388. end;
  389.  
  390. procedure tworzenie_2(var tab:tablica; var tab_c : tablica; gracz:string);
  391. var
  392. m, p, b : integer;
  393. begin
  394. al_textout_ex(al_screen, al_font, 'Stworz 3 masztowiec', 310, 400, al_makecol(0,0,0), -1);
  395. for b:=5 to 7 do
  396. begin
  397. wyswietl(tab,tab_c, gracz,1);
  398. m:=0;
  399. al_textout_ex(al_screen, al_font, 'Stworz 2 masztowiec', 310, 400, al_makecol(200,200,200), -1);
  400. wyswietl_c(tab, tab_c);
  401. repeat
  402. begin
  403. mb:=0;
  404. repeat
  405. pozycja_myszki();
  406. przekroczenie_1(435,750,65,360);
  407. until ((mb=1)AND(przekroczenie_1(435,750,65,360)=false));
  408. if(warunek_tworzenia_1(tab, b)=true) then
  409. begin
  410. if (m>0) then
  411. begin
  412. if (warunek_tworzenia_2(tab,b)=true) then
  413. begin
  414. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=b;
  415. end
  416. else if (warunek_tworzenia_2(tab,b)=false) then
  417. begin
  418. al_textout_ex(al_screen, al_font, 'Statek musi byc polaczony', 250, 420, al_makecol(200,200,200), -1);
  419. end;
  420. end
  421. else
  422. begin
  423. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=b;
  424. end;
  425. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  426. m:=m+1;
  427. p:=1;
  428. end
  429. else if(warunek_tworzenia_1(tab, b)=false) then
  430. begin
  431. al_textout_ex(al_screen, al_font, 'Nowo utworzony statek nie moze dotykac statku wczesniej utworzonego', 310, 420, al_makecol(200,200,200), -1);
  432. p:=1;
  433. end;
  434. if (p=0) then
  435. begin
  436. if(warunek_tworzenia_2(tab, b)=true)then
  437. begin
  438. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=b;
  439. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  440. m:=m+1;
  441. p:=1;
  442. end
  443. else if (warunek_tworzenia_2(tab, b)=false) then
  444. begin
  445. al_textout_ex(al_screen, al_font, 'Statek musi byc polaczony', 250, 420, al_makecol(200,200,200), -1);
  446. end;
  447. end;
  448. wyswietl_c(tab, tab_c);
  449. end;
  450. p:=1;
  451. until (m=2);
  452. wyswietl_c(tab, tab_c);
  453. end;
  454. end;
  455.  
  456. procedure tworzenie_1(var tab:tablica; var tab_c : tablica; gracz:string);
  457. var
  458. m, a : integer;
  459. begin
  460. al_textout_ex(al_screen, al_font, 'Stworz 2 masztowiec', 310, 400, al_makecol(0,0,0), -1);
  461. for a:=1 to 4 do
  462. begin
  463. wyswietl(tab,tab_c, gracz,2);
  464. m:=0;
  465. al_textout_ex(al_screen, al_font, 'Stworz 1 masztowiec', 310, 400, al_makecol(200,200,200), -1);
  466. wyswietl_c(tab, tab_c);
  467. repeat
  468. begin
  469. mb:=0;
  470. repeat
  471. pozycja_myszki();
  472. przekroczenie_1(435,750,65,360);
  473. until ((mb=1) AND (przekroczenie_1(435,750,65,360)=false));
  474. if((warunek_tworzenia_1(tab,a)=true) AND (tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]=0))then
  475. begin
  476. tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]:=a;
  477. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  478. m:=m+1;
  479. end
  480. else if(warunek_tworzenia_1(tab,a)=false) then
  481. begin
  482. al_textout_ex(al_screen, al_font, 'Nowo utworzony statek nie moze dotykac statku wczesniej utworzonego', 310, 420, al_makecol(200,200,200), -1);
  483. end
  484. else if (tab[((my-65)DIV 30)+1][((mx-435)DIV 30)+1]<>0) then
  485. begin
  486. al_textout_ex(al_screen, al_font, 'Tu jest statek', 310, 420, al_makecol(200,200,200), -1);
  487. end
  488. end;
  489. wyswietl_c(tab, tab_c);
  490. until (m=1);
  491. wyswietl_c(tab, tab_c);
  492. end;
  493. wyswietl_c(tab, tab_c);
  494. delay(1000);
  495. end;
  496.  
  497. procedure tworzenie_4_k;
  498. var
  499. typ_statku, x, y, stw : integer;
  500. begin
  501. stw:=0;
  502. repeat
  503. randomize();
  504. typ_statku:=random(13)+1;
  505. if(typ_statku=1) then
  506. begin
  507. y:=random(8)+1;
  508. x:=random(9)+2;
  509. tab2[y][x]:=10;
  510. tab2[y+1][x]:=10;
  511. tab2[y+2][x]:=10;
  512. tab2[y+2][x-1]:=10;
  513. break;
  514. end;
  515. if(typ_statku=2) then
  516. begin
  517. y:=random(8)+1;
  518. x:=random(9)+1;
  519. tab2[y][x]:=10;
  520. tab2[y+1][x]:=10;
  521. tab2[y+2][x]:=10;
  522. tab2[y+2][x+1]:=10;
  523. break;
  524. end;
  525. if(typ_statku=3) then
  526. begin
  527. y:=random(7)+1;
  528. x:=random(10)+1;
  529. tab2[y][x]:=10;
  530. tab2[y+1][x]:=10;
  531. tab2[y+2][x]:=10;
  532. tab2[y+3][x]:=10;
  533. break;
  534. end;
  535. if(typ_statku=4) then
  536. begin
  537. y:=random(10)+1;
  538. x:=random(7)+1;
  539. tab2[y][x]:=10;
  540. tab2[y][x+1]:=10;
  541. tab2[y][x+2]:=10;
  542. tab2[y][x+3]:=10;
  543. break;
  544. end;
  545. if(typ_statku=5) then
  546. begin
  547. y:=random(9)+1;
  548. x:=random(8)+1;
  549. tab2[y][x]:=10;
  550. tab2[y][x+1]:=10;
  551. tab2[y][x+2]:=10;
  552. tab2[y+1][x+1]:=10;
  553. break;
  554. end;
  555. if(typ_statku=6) then
  556. begin
  557. y:=random(9)+2;
  558. x:=random(8)+1;
  559. tab2[y][x]:=10;
  560. tab2[y][x+1]:=10;
  561. tab2[y][x+2]:=10;
  562. tab2[y-1][x+2]:=10;
  563. break;
  564. end;
  565. if(typ_statku=7) then
  566. begin
  567. y:=random(9)+2;
  568. x:=random(8)+1;
  569. tab2[y][x]:=10;
  570. tab2[y][x+1]:=10;
  571. tab2[y][x+2]:=10;
  572. tab2[y-1][x]:=10;
  573. break;
  574. end;
  575. if(typ_statku=8) then
  576. begin
  577. y:=random(9)+2;
  578. x:=random(8)+1;
  579. tab2[y][x]:=10;
  580. tab2[y][x+1]:=10;
  581. tab2[y][x+2]:=10;
  582. tab2[y-1][x+1]:=10;
  583. break;
  584. end;
  585. if(typ_statku=9) then
  586. begin
  587. y:=random(9)+1;
  588. x:=random(8)+1;
  589. tab2[y][x]:=10;
  590. tab2[y+1][x]:=10;
  591. tab2[y][x+1]:=10;
  592. tab2[y][x+2]:=10;
  593. break;
  594. end;
  595. if(typ_statku=10) then
  596. begin
  597. y:=random(9)+1;
  598. x:=random(8)+1;
  599. tab2[y][x]:=10;
  600. tab2[y][x+1]:=10;
  601. tab2[y][x+2]:=10;
  602. tab2[y+1][x+2]:=10;
  603. break;
  604. end;
  605. if(typ_statku=11) then
  606. begin
  607. y:=random(9)+1;
  608. x:=random(9)+1;
  609. tab2[y][x]:=10;
  610. tab2[y+1][x+1]:=10;
  611. tab2[y][x+1]:=10;
  612. tab2[y+1][x]:=10;
  613. break;
  614. end;
  615. if(typ_statku=12) then
  616. begin
  617. y:=random(8)+1;
  618. x:=random(9)+2;
  619. tab2[y][x]:=10;
  620. tab2[y+1][x]:=10;
  621. tab2[y+2][x]:=10;
  622. tab2[y][x-1]:=10;
  623. break;
  624. end;
  625. if(typ_statku=13) then
  626. begin
  627. y:=random(8)+1;
  628. x:=random(9)+1;
  629. tab2[y][x]:=10;
  630. tab2[y+1][x]:=10;
  631. tab2[y+2][x]:=10;
  632. tab2[y][x+1]:=10;
  633. break;
  634. end;
  635. until (stw=1);
  636. end;
  637.  
  638. procedure tworzenie_3_k();
  639. var
  640. typ_statku, it1, it2, x, y, stw, a, war : integer;
  641. begin
  642. stw:=0;
  643. for a:=8 to 9 do
  644. begin
  645. war:=0;
  646. repeat
  647. randomize();
  648. typ_statku:=random(6)+1;
  649. if (typ_statku=1)then
  650. begin
  651. y:=random(10)+1;
  652. x:=random(8)+1;
  653. for it1:=-1 to 1 do
  654. begin
  655. for it2:=-1 to 1 do
  656. begin
  657. if ((tab2[y+it1][x+it2]=0) AND (tab2[y+it1][x+1+it2]=0) AND (tab2[y+it1][x+2+it2]=0))then
  658. begin
  659. war:=war+1;
  660. end;
  661. end;
  662. end;
  663. if (war=9) then
  664. begin
  665. tab2[y][x]:=a;
  666. tab2[y][x+1]:=a;
  667. tab2[y][x+2]:=a;
  668. break;
  669. end;
  670. war:=0;
  671. end;
  672. if (typ_statku=2)then
  673. begin
  674. y:=random(9)+1;
  675. x:=random(9)+1;
  676. for it1:=-1 to 1 do
  677. begin
  678. for it2:=-1 to 1 do
  679. begin
  680. if ((tab2[y+it1][x+it2]=0) AND (tab2[y+it1][x+1+it2]=0) AND (tab2[y+1+it1][x+1+it2]=0))then
  681. begin
  682. war:=war+1;
  683. end;
  684. end;
  685. end;
  686. if (war=9) then
  687. begin
  688. tab2[y][x]:=a;
  689. tab2[y][x+1]:=a;
  690. tab2[y+1][x+1]:=a;
  691. break;
  692. end;
  693. war:=0;
  694. end;
  695. if (typ_statku=3)then
  696. begin
  697. y:=random(9)+1;
  698. x:=random(9)+1;
  699. for it1:=-1 to 1 do
  700. begin
  701. for it2:=-1 to 1 do
  702. begin
  703. if ((tab2[y+it1][x+it2]=0) AND (tab2[y+it1][x+1+it2]=0) AND (tab2[y+1+it1][x+it2]=0))then
  704. begin
  705. war:=war+1;
  706. end;
  707. end;
  708. end;
  709. if (war=9) then
  710. begin
  711. tab2[y][x]:=a;
  712. tab2[y][x+1]:=a;
  713. tab2[y+1][x]:=a;
  714. break;
  715. end;
  716. war:=0;
  717. end;
  718. if (typ_statku=4)then
  719. begin
  720. y:=random(9)+1;
  721. x:=random(9)+1;
  722. for it1:=-1 to 1 do
  723. begin
  724. for it2:=-1 to 1 do
  725. begin
  726. if ((tab2[y+it1][x+it2]=0) AND (tab2[y+1+it1][x+1+it2]=0) AND (tab2[y+1+it1][x+it2]=0))then
  727. begin
  728. war:=war+1;
  729. end;
  730. end;
  731. end;
  732. if (war=9) then
  733. begin
  734. tab2[y][x]:=a;
  735. tab2[y+1][x]:=a;
  736. tab2[y+1][x+1]:=a;
  737. break;
  738. end;
  739. war:=0;
  740. end;
  741. if (typ_statku=5)then
  742. begin
  743. y:=random(9)+2;
  744. x:=random(9)+1;
  745. for it1:=-1 to 1 do
  746. begin
  747. for it2:=-1 to 1 do
  748. begin
  749. if ((tab2[y+it1][x+it2]=0) AND (tab2[y+it1][x+1+it2]=0) AND (tab2[y-1+it1][x+1+it2]=0))then
  750. begin
  751. war:=war+1;
  752. end;
  753. end;
  754. end;
  755. if (war=9) then
  756. begin
  757. tab2[y][x]:=a;
  758. tab2[y][x+1]:=a;
  759. tab2[y-1][x+1]:=a;
  760. break;
  761. end;
  762. war:=0;
  763. end;
  764. if (typ_statku=6)then
  765. begin
  766. y:=random(8)+1;
  767. x:=random(10)+1;
  768. for it1:=-1 to 1 do
  769. begin
  770. for it2:=-1 to 1 do
  771. begin
  772. if ((tab2[y+it1][x+it2]=0) AND (tab2[y+1+it1][x+it2]=0) AND (tab2[y+2+it1][x+it2]=0))then
  773. begin
  774. war:=war+1;
  775. end;
  776. end;
  777. end;
  778. if (war=9) then
  779. begin
  780. tab2[y][x]:=a;
  781. tab2[y+1][x]:=a;
  782. tab2[y+2][x]:=a;
  783. break;
  784. end;
  785. war:=0;
  786. end;
  787. until (stw=1) ;
  788. end;
  789. end;
  790.  
  791. procedure tworzenie_2_k();
  792. var
  793. stw, typ_statku, it1, it2, war, a, x, y : integer;
  794. begin
  795. stw:=0;
  796. for a:=5 to 7 do
  797. begin
  798. war:=0;
  799. repeat
  800. randomize();
  801. typ_statku:=random(2)+1;
  802. if (typ_statku=1)then
  803. begin
  804. y:=random(10)+1;
  805. x:=random(9)+1;
  806. for it1:=-1 to 1 do
  807. begin
  808. for it2:=-1 to 1 do
  809. begin
  810. if ((tab2[y+it1][x+it2]=0) AND (tab2[y+it1][x+1+it2]=0))then
  811. begin
  812. war:=war+1;
  813. end;
  814. end;
  815. end;
  816. if (war=9) then
  817. begin
  818. tab2[y][x]:=a;
  819. tab2[y][x+1]:=a;
  820. break;
  821. end;
  822. war:=0;
  823. end;
  824. if (typ_statku=2)then
  825. begin
  826. y:=random(9)+1;
  827. x:=random(10)+1;
  828. for it1:=-1 to 1 do
  829. begin
  830. for it2:=-1 to 1 do
  831. begin
  832. if ((tab2[y+it1][x+it2]=0) AND (tab2[y+1+it1][x+it2]=0))then
  833. begin
  834. war:=war+1;
  835. end;
  836. end;
  837. end;
  838. if (war=9) then
  839. begin
  840. tab2[y][x]:=a;
  841. tab2[y+1][x]:=a;
  842. break;
  843. end;
  844. war:=0;
  845. end;
  846. until (stw=1);
  847. end;
  848. end;
  849.  
  850. procedure tworzenie_1_k();
  851. var
  852. it1, it2, b, war, stw,x, y :integer;
  853. begin
  854. stw:=0;
  855. for b:=1 to 4 do
  856. begin
  857. war:=0;
  858. repeat
  859. y:=random(10)+1;
  860. x:=random(10)+1;
  861. for it1:=-1 to 1 do
  862. begin
  863. for it2:=-1 to 1 do
  864. begin
  865. if (tab2[y+it1][x+it2]=0) then
  866. begin
  867. war:=war+1;
  868. end;
  869. end;
  870. end;
  871. if (war=9) then
  872. begin
  873. tab2[y][x]:=b;
  874. break;
  875. end;
  876. war:=0;
  877. until (stw=1);
  878. end;
  879. end;
  880.  
  881. procedure ruch_komputera(var komp : integer; var _1 : integer; var _2 : integer; var typ : integer);
  882. var
  883. x, y, it1, it2,m, zm,a,b, myk, odmyk : integer;
  884. begin
  885. zm:=0;
  886. if (komp=0) then
  887. begin
  888. m:=0;
  889. repeat
  890. randomize();
  891. y:=random(10)+1;
  892. x:=random(10)+1;
  893. until (tab2_c[y][x]=0);
  894. if ((tab1[y][x]=0) AND (tab2_c[y][x]=0)) then
  895. begin
  896. tab1[y][x]:=-9;
  897. tab2_c[y][x]:=-1;
  898. komp:=0;
  899. zm:=1;
  900. end;
  901. if (zm=0) then
  902. begin
  903. for it1:=-1 to 1 do
  904. begin
  905. for it2:=-1 to 1 do
  906. begin
  907. if ((it1=0) AND (it2=0)) then break;
  908. if ((tab1[y+it1][x+it2]=0) AND (tab1[y][x]>0) AND (tab2_c[y][x]=0)) then
  909. begin
  910. m:=m+1;
  911. end;
  912. end;
  913. end;
  914. if(m=8) then
  915. begin
  916. tab1[y][x]:=-11;
  917. tab2_c[y][x]:=-3;
  918. komp:=0;
  919. zm:=1;
  920. end;
  921. if (m<8) then
  922. begin
  923. typ:=tab1[y][x];
  924. tab1[y][x]:=-10;
  925. tab2_c[y][x]:=-2;
  926. _1:=y;
  927. _2:=x;
  928. komp:=1;
  929. zm:=1;
  930. end;
  931. end;
  932. end;
  933. if ((komp=1) AND (zm=0)) then
  934. begin
  935. odmyk:=1;
  936. writeln('1');
  937. for it1:=-1 to 1 do
  938. begin
  939. for it2:=-1 to 1 do
  940. begin
  941. if (((it1=0)OR(it2=0))AND (tab2_c[_1+it1][_2+it2]=0) AND (_1+it1<=10) AND (_1+it1>=1) AND (_2+it2<=10) AND (_2+it2>=1)) then
  942. begin
  943. odmyk:=2;
  944. break;
  945. end
  946. else continue;
  947. end;
  948. if (odmyk=2) then break;
  949. end;
  950. if(tab1[_1+it1][_2+it2]=typ) then
  951. begin
  952. tab1[_1+it1][_2+it2]:=-10;
  953. tab2_c[_1+it1][_2+it2]:=-2;
  954. myk:=1;
  955. for a:=-3 to 3 do
  956. begin
  957. for b:=-3 to 3 do
  958. begin
  959. if (tab1[_1+a][_2+b]=typ) then
  960. begin
  961. komp:=1;
  962. myk:=2;
  963. break;
  964. end;
  965. end;
  966. if (myk=2) then break;
  967. end;
  968. if (myk=1) then
  969. begin
  970. for a:=-3 to 3 do
  971. begin
  972. for b:=-3 to 3 do
  973. begin
  974. if (tab1[_1+a][_2+b]=-10) then
  975. begin
  976. if ((_1+a>11) OR (_1+a<0) OR (_2+b>11) OR (_2+b<0)) then
  977. break;
  978. komp:=0;
  979. tab1[_1+a][_2+b]:=-11;
  980. tab2_c[_1+a][_2+b]:=-3;
  981. komp:=0;
  982. end;
  983. end;
  984. end;
  985. end;
  986. _1:=_1+it1;
  987. _2:=_2+it2;
  988. end
  989. else if (tab1[_1+it1][_2+it2]=0) then
  990. begin
  991. tab1[_1+it1][_2+it2]:=-9;
  992. tab2_c[_1+it1][_2+it2]:=-1;
  993. komp:=1;
  994. end;
  995. end;
  996. end;
  997.  
  998. procedure tworzenie(var tab:tablica; var tab_c : tablica; gracz : string);
  999. begin
  1000. tworzenie_4(tab,tab_c, gracz);
  1001. tworzenie_3(tab,tab_c, gracz);
  1002. tworzenie_2(tab,tab_c, gracz);
  1003. tworzenie_1(tab,tab_c, gracz);
  1004. end;
  1005.  
  1006. procedure tworzenie_k ();
  1007. begin
  1008. tworzenie_4_k();
  1009. tworzenie_3_k();
  1010. tworzenie_2_k();
  1011. tworzenie_1_k();
  1012. end;
  1013.  
  1014. procedure przerwa();
  1015. var
  1016. m: integer;
  1017. begin
  1018. al_clear_to_color( al_screen, al_makecol( 0, 0, 0 ) );
  1019. for m:=15 downto 11 do
  1020. begin
  1021. al_textout_ex(al_screen, al_font, 'Zmiana zawodnika, masz sekund', 310, 300, al_makecol(200,200,200), -1);
  1022. al_textout_ex(al_screen, al_font, litery[m], 500, 300, al_makecol(200,200,200), -1);
  1023. delay(1000);
  1024. al_clear_to_color( al_screen, al_makecol( 0, 0, 0 ) );
  1025. end;
  1026. al_clear_to_color( al_screen, al_makecol( 0, 0, 0 ) );
  1027. end;
  1028.  
  1029. function powitalny() : byte;
  1030. begin
  1031. al_textout_centre_ex(al_screen,al_font,'WITAJ W GRZE W STATKI', ScreenWidth div 2, ScreenHeight div 3, al_makecol(200,200,200), -1);
  1032. al_textout_ex(al_screen, al_font, 'Wykonal: Kamil Sobolewski Informatyka EAIIB 2015', 800, 700, al_makecol(200,200,200), -1);
  1033. al_rectfill( al_screen, 470, 270 , 730, 320, al_makecol( 0, 0, 0 ) );
  1034. al_rect( al_screen, 470, 270, 730, 320, al_makecol( 200, 200, 200 ) );
  1035. al_textout_ex(al_screen, al_font, 'Gra z innym uzytkownikiem', 500, 295, al_makecol(200,200,200), -1);
  1036. al_rectfill( al_screen, 470, 330 , 730, 380, al_makecol( 0, 0, 0 ) );
  1037. al_rect( al_screen, 470, 330, 730, 390, al_makecol( 200, 200, 200 ) );
  1038. al_textout_ex(al_screen, al_font, 'Gra z komputerem', 540, 360, al_makecol(200,200,200), -1);
  1039. repeat
  1040. pozycja_myszki();
  1041. if((mx>470) AND (mx<730) AND (my<320) AND (my>270))then
  1042. begin
  1043. al_rectfill( al_screen, 470, 270 , 730, 320, al_makecol( 200, 200, 200 ) );
  1044. al_rect( al_screen, 470, 270, 730, 320, al_makecol( 200, 200, 200 ) );
  1045. al_textout_ex(al_screen, al_font, 'Gra z innym uzytkownikiem', 500, 295, al_makecol(0,0,0), -1);
  1046. end;
  1047. if((mx>470) AND (mx<730) AND (my<390) AND (my>330))then
  1048. begin
  1049. al_rectfill( al_screen, 470, 330 , 730, 390, al_makecol( 200, 200, 200 ) );
  1050. al_rect( al_screen, 470, 330, 730, 390, al_makecol( 200, 200, 200 ) );
  1051. al_textout_ex(al_screen, al_font, 'Gra z komputerem', 540, 360, al_makecol(0,0,0), -1);
  1052. end;
  1053. until (mb=1);
  1054. if((mx>470) AND (mx<730) AND (my<390) AND (my>330))then
  1055. begin
  1056. powitalny:=2;
  1057. end;
  1058. if((mx>470) AND (mx<730) AND (my<320) AND (my>270))then
  1059. begin
  1060. powitalny:=1;
  1061. end;
  1062. end;
  1063.  
  1064. function sprawdzenie ( var tab : tablica; a: integer; b: integer) : integer;
  1065. begin
  1066. if (tab[a][b]>0) then
  1067. begin
  1068. if (((tab[a+1][b]=0) OR (tab[a+1][b]=-10)OR (tab[a+1][b]=-9)) AND ((tab[a-1][b]=0) OR (tab[a-1][b]=-10)OR (tab[a-1][b]=-9)) AND ((tab[a][b+1]=0) OR (tab[a][b+1]=-10)OR (tab[a][b+1]=-9)) AND ((tab[a][b-1]=0)OR (tab[a][b-1]=-10)OR (tab[a][b-1]=-9)))then
  1069. begin
  1070. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  1071. al_textout_ex(al_screen, al_font, 'Trafiony, zatopiony!', 310, 420, al_makecol(200,200,200), -1);
  1072. tab[a][b]:=-11;
  1073. sprawdzenie:=1;
  1074. end
  1075. else
  1076. begin
  1077. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  1078. al_textout_ex(al_screen, al_font, 'Trafiony, niezatapiony!', 310, 420, al_makecol(200,200,200), -1);
  1079. tab[a][b]:=-10;
  1080. sprawdzenie:=2;
  1081. end;
  1082. end
  1083. else
  1084. begin
  1085. tab[a][b]:=-9;
  1086. sprawdzenie:=3;
  1087. al_rectfill( al_screen, 240, 415 , 1000, 440, al_makecol( 0, 0, 0 ) );
  1088. al_textout_ex(al_screen, al_font, 'Pudlo!', 310, 420, al_makecol(200,200,200), -1);
  1089. end;
  1090. end;
  1091.  
  1092. procedure ruch ( var tab : tablica; var tab_c : tablica; var tab_wys : tablica;gracz: string);
  1093. var
  1094. m, a, b, i, iterator1,iterator2, check : integer;
  1095. begin
  1096. if (tryb=1) then
  1097. begin
  1098. clear();
  1099. end;
  1100. m:=0;
  1101. i:=0;
  1102. wyswietl(tab_wys, tab_c, gracz, -2);
  1103. al_textout_ex(al_screen, al_font, 'Twoj ruch, wybierz pole i strzelaj', 310, 400, al_makecol(200,200,200), -1);
  1104. repeat
  1105. begin
  1106. mb:=0;
  1107. repeat
  1108. pozycja_myszki();
  1109. przekroczenie_1(35, 350, 65, 360);
  1110. until ((mb=1) AND (przekroczenie_1(35,350,65,360)=false));
  1111. if ((tab_c[((my-65)DIV 30)+1][((mx-35)DIV 30)+1]<>-1) AND (tab_c[((my-65)DIV 30)+1][((mx-35) DIV 30)+1]<>-2) AND (tab_c[((my-65)DIV 30)+1][((mx-35) DIV 30)+1]<>-3)) then
  1112. begin
  1113. a:=((my-65)DIV 30)+1;
  1114. b:=((mx-35) DIV 30)+1;
  1115. check:=sprawdzenie(tab,a,b);
  1116. if (check=1) then
  1117. begin
  1118. tab_c[a][b]:=-3;
  1119. for iterator1:=-3 to 3 do
  1120. begin
  1121. for iterator2:=-3 to 3 do
  1122. begin
  1123. if((iterator1=0) AND (iterator2=0)) then break;
  1124. if(tab[a+iterator1][b+iterator2]=-10) then
  1125. begin
  1126. if ((a+iterator1>11) OR (a+iterator1<0) OR (b+iterator2>11) OR (b+iterator2<0)) then
  1127. break;
  1128. tab[a+iterator1][b+iterator2]:=-11;
  1129. tab_c[a+iterator1][b+iterator2]:=-3;
  1130. end;
  1131. end;
  1132. end;
  1133. end;
  1134. if (check=2) then tab_c[a][b]:=-2;;
  1135. if (check=3) then tab_c[a][b]:=-1;
  1136. m:=1;
  1137. if (i<>0) then
  1138. begin
  1139. al_textout_ex(al_screen, al_font, 'To pole bylo wybrane wczesniej', 310, 420, al_makecol(0,0,0), -1);
  1140. end;
  1141. end
  1142. else
  1143. begin
  1144. al_textout_ex(al_screen, al_font, 'To pole bylo wybrane wczesniej', 310, 420, al_makecol(200,200,200), -1);
  1145. end;
  1146. i:=i+1;
  1147. end;
  1148. until (m=1);
  1149. wyswietl_c(tab_wys, tab_c);
  1150. delay(1000);
  1151. end;
  1152.  
  1153. function warunek_gry (tab1 : tablica; tab2 : tablica) : integer;
  1154. var
  1155. i, j : integer;
  1156. licznik1, licznik2 : integer;
  1157. begin
  1158. licznik1:=0;
  1159. licznik2:=0;
  1160. for i:=1 to 10 do
  1161. begin
  1162. for j:=1 to 10 do
  1163. begin
  1164. if (tab1[i][j]<=0) then licznik1:=licznik1+1;
  1165. if (tab2[i][j]<=0) then licznik2:=licznik2+1;
  1166. end;
  1167. end;
  1168. if (licznik1=100) then warunek_gry:=0;
  1169. if (licznik2=100) then warunek_gry:=1;
  1170. if((licznik1<>100) AND (licznik2<>100))then warunek_gry:=2;
  1171. end;
  1172.  
  1173. procedure dwoch_graczy ();
  1174. var
  1175. wygrany : string;
  1176. warunek : integer;
  1177. begin
  1178. wyswietl(tab1,tab1_c, 'Gracz 1.',-1);
  1179. tworzenie(tab1,tab1_c, 'Gracz 1.');
  1180. przerwa();
  1181. wyswietl(tab2,tab2_c, 'Gracz 2.', -1);
  1182. tworzenie(tab2,tab2_c, 'Gracz 2.');
  1183. przerwa();
  1184. warunek:=5;
  1185. repeat
  1186. ruch(tab2, tab1_c, tab1, 'Gracz 1.');
  1187. warunek:=warunek_gry(tab1,tab2);
  1188. if((warunek=0) OR (warunek=1)) then break;
  1189. delay(1500);
  1190. przerwa();
  1191. clear();
  1192. ruch(tab1, tab2_c, tab2, 'Gracz 2.');
  1193. delay(1500);
  1194. warunek:=warunek_gry(tab1,tab2);
  1195. if((warunek=0) OR (warunek=1)) then break;
  1196. przerwa();
  1197. clear();
  1198. until ((warunek=0) OR (warunek=1));
  1199. if (warunek_gry(tab1, tab2)=0) then wygrany:='Gracz 2.';
  1200. if (warunek_gry(tab1, tab2)=1) then wygrany:='Gracz 1.';
  1201. clear();
  1202. koniec(wygrany);
  1203. end;
  1204.  
  1205. procedure komputer ();
  1206. var
  1207. wygrany : string;
  1208. warunek, zm : integer;
  1209. begin
  1210. wyswietl(tab1,tab1_c, 'Gracz 1.',-1);
  1211. tworzenie(tab1,tab1_c, 'Gracz 1.');
  1212. tworzenie_k();
  1213. warunek:=5;
  1214. zm:=0;
  1215. repeat
  1216. if(zm=0) then clear;
  1217. ruch(tab2, tab1_c, tab1, 'Gracz 1.');
  1218. warunek:=warunek_gry(tab1,tab2);
  1219. if((warunek=0) OR (warunek=1)) then break;
  1220. ruch_komputera(komp, _1, _2, typ);
  1221. warunek:=warunek_gry(tab1,tab2);
  1222. if((warunek=0) OR (warunek=1)) then break;
  1223. zm:=zm+1;
  1224. until ((warunek=0) OR (warunek=1));
  1225. if (warunek_gry(tab1, tab2)=0) then wygrany:='Gracz 2.';
  1226. if (warunek_gry(tab1, tab2)=1) then wygrany:='Gracz 1.';
  1227. clear();
  1228. koniec(wygrany);
  1229. end;
  1230.  
  1231. begin
  1232. inicjalizuj();
  1233. tryb:=powitalny();
  1234. delay(500);
  1235. clear();
  1236. case tryb of
  1237. 1 : dwoch_graczy();
  1238. 2 : komputer();
  1239. end;
  1240. al_readkey;
  1241. al_exit();
  1242. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement