Advertisement
Andrey_Mironenko

Untitled

Dec 18th, 2013
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.83 KB | None | 0 0
  1. Uses Crt;
  2.  
  3. Const
  4. w1= 80;
  5. h1= 25;
  6. frq_g= 150;
  7. land= 1;
  8. ocean= 0;
  9. rock= 2;
  10. ice= 4;
  11. spec= 5;
  12. frq_2= 3;
  13.  
  14. type
  15. tmap= array [1..w1, 1..h1] of integer;
  16.  
  17. var
  18. map: tmap;
  19. temp_w, temp_h, temp_r, t_wx, t_wy: integer;
  20. test1_x, test1_y, test2, test3, test4, test5: integer;
  21. f: text;
  22. result1: string;
  23.  
  24. function minus(c: integer): integer;
  25. begin
  26. if c-1<0 then minus:=c
  27. else
  28. if c-1<0 then minus:=c
  29. else
  30. if c-1=0 then minus:=c
  31. else
  32. if c-1=0 then minus:=c
  33. else
  34. minus:= c-1;
  35. end;
  36.  
  37. function plus_w(c: integer): integer;
  38. begin
  39. if c+1>w1 then plus_w:=c
  40. else
  41. plus_w:=c+1;
  42. end;
  43.  
  44. function plus_h(c: integer): integer;
  45. begin
  46. if c+1>h1 then plus_h:=c
  47. else
  48. plus_h:=c+1;
  49. end;
  50.  
  51. procedure arr_over_test;
  52. begin
  53. if test1_x>w1 then test1_x:=temp_w
  54. else
  55. if test1_y>h1 then test1_y:=temp_h
  56. else
  57. if test1_x<0 then test1_x:=temp_w
  58. else
  59. if test1_y<0 then test1_y:=temp_h
  60. else
  61. if test1_x=0 then test1_x:=temp_w
  62. else
  63. if test1_y=0 then test1_y:=temp_h
  64. else
  65. end;
  66.  
  67. procedure spec_gen;
  68. begin
  69. test5:=frq_2;
  70. arr_over_test;
  71. test5:=test5-1;
  72. if Random(test5)= 2 then
  73. begin
  74. map[test1_x, test1_y]:=spec;
  75. end
  76. else
  77. map[test1_x, test1_y]:=land
  78. end;
  79.  
  80. procedure continent;
  81. begin
  82. map[temp_w, temp_h]:=rock;
  83. t_wx:= wherex;
  84. t_wy:= wherey;
  85.  
  86. // вверх-вниз V
  87.  
  88. test1_x:= temp_w;
  89. test1_y:= temp_h+1;
  90. arr_over_test;
  91. spec_gen;
  92.  
  93. test1_x:= temp_w;
  94. test1_y:= temp_h-1;
  95. arr_over_test;
  96. spec_gen;
  97.  
  98. test1_x:= temp_w+1;
  99. test1_y:= temp_h;
  100. arr_over_test;
  101. spec_gen;
  102.  
  103. test1_x:= temp_w-1;
  104. test1_y:= temp_h;
  105. arr_over_test;
  106. spec_gen;
  107.  
  108. // диагональ V
  109.  
  110. test1_x:= temp_w+1;
  111. test1_y:= temp_h+1;
  112. arr_over_test;
  113. spec_gen;
  114.  
  115. test1_x:= temp_w-1;
  116. test1_y:= temp_h+1;
  117. arr_over_test;
  118. spec_gen;
  119.  
  120. test1_x:= temp_w+1;
  121. test1_y:= temp_h-1;
  122. arr_over_test;
  123. spec_gen;
  124.  
  125. test1_x:= temp_w-1;
  126. test1_y:= temp_h-1;
  127. arr_over_test;
  128. spec_gen;
  129.  
  130. end;
  131.  
  132. procedure delisl;
  133. begin
  134. test3:=0;
  135. if map[plus_w(temp_w), temp_h]= ocean then test3:=test3+1
  136. else
  137. if map[minus(temp_w), temp_h]= ocean then test3:=test3+1
  138. else
  139. if map[temp_w, plus_h(temp_h)]= ocean then test3:=test3+1
  140. else
  141. if map[temp_w, minus(temp_h)]= ocean then test3:=test3+1;
  142. if test3>=3 then map[temp_w, temp_h]:=ocean
  143. else
  144. end;
  145.  
  146. begin
  147. ClrScr;
  148. randomize();
  149.  
  150.  
  151. for temp_r:= 1 to frq_g do
  152. map[Random(79)+1, Random(24)+1]:=spec;
  153.  
  154. for temp_w:= 1 to w1 do
  155. for temp_h:= 1 to h1 do
  156. begin
  157. begin
  158. if map[temp_w, temp_h]= spec then continent
  159. else
  160. end;
  161. if Random(3)=1 then test4:=2
  162. else test4:=1;
  163. if Random(5)=1 then
  164. map[temp_w, temp_h]:= Random(test4)
  165. else
  166. end;
  167.  
  168. for temp_w:= 1 to w1 do
  169. for temp_h:= 1 to h1 do
  170. begin
  171. if map[temp_w, temp_h]=land then delisl
  172. else
  173. end;
  174.  
  175. for temp_w:= 1 to 10 do
  176. for temp_h:= 1 to h1 do
  177. begin
  178. if map[temp_w, temp_h]=land then map[temp_w, temp_h]:=ice
  179. else
  180. if map[temp_w, temp_h]=rock then map[temp_w, temp_h]:=ice
  181. else
  182. end;
  183.  
  184. for temp_w:= 75 to w1 do
  185. for temp_h:= 1 to h1 do
  186. begin
  187. if map[temp_w, temp_h]=land then map[temp_w, temp_h]:=ice
  188. else
  189. if map[temp_w, temp_h]=rock then map[temp_w, temp_h]:=ice
  190. else
  191. end;
  192.  
  193. Assign(f, 'D:\SAVEDMAP.txt');
  194. rewrite(f);
  195. for temp_h:= 1 to h1 do
  196. begin
  197. writeln(f, '');
  198. for temp_w:= 1 to w1 do
  199. begin
  200. str(map[temp_w, temp_h], result1);
  201. write(f, result1);
  202. end;
  203. end;
  204.  
  205. for temp_w:= 1 to w1 do map[temp_w, 1]:=ice;
  206.  
  207. for temp_w:= 1 to 80 do
  208. for temp_h:= 1 to h1 do
  209. begin
  210. if map[temp_w, temp_h]= land then textcolor(2)
  211. else
  212. if map[temp_w, temp_h]= ocean then textcolor(1)
  213. else
  214. if map[temp_w, temp_h]= rock then textcolor(6)
  215. else
  216. if map[temp_w, temp_h]= ice then textcolor(15);
  217. write('█');
  218. end;
  219. Readln;
  220. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement