MISHA.PAS 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. Uses Crt,dos,graph;
  2. Const fx=40;
  3. fy=10;
  4. Var
  5. x : array[0..2000] of byte;
  6. y : array[0..2000] of byte;
  7. xb,c,e,s,yb,xx,xy,xe,ye : byte;
  8. e1,e2,e3,e4 : word;
  9. ch : char;
  10. l,i,right,top : 0..2000;
  11. dr,f,mo,speed,s1,score,t,n : integer;
  12. otv : string[3];
  13. Procedure SetCursorSize( c_Start, c_End : Byte );
  14. { 0 .. 32
  15. Устанавливает форму курсора}
  16. var
  17. Regs : Registers;
  18. BEGIN
  19. with Regs do begin
  20. AH := $01; {функция формы курсора}
  21. CH := c_Start; {стартовая линия курсора}
  22. CL := c_End; {конечная линия курсора}
  23. end;
  24. Intr( $10, Regs ) {вызов прерывания 10H БСВВ}
  25. End;
  26. Procedure SetNoCursor; {Невидимый курсора}
  27. BEGIN
  28. SetCursorSize( 32, 0 )
  29. END;
  30. begin
  31. ClrScr;
  32. s1:=0; t:=0; n:=0;
  33. dr:=detect;
  34. initgraph(dr,mo,'bgi');
  35. SetColor(0);
  36. SetBkColor(0);
  37. SetFillStyle(4,9);
  38. repeat
  39. s1:=s1+5;
  40. t:=t+5;
  41. n:=n+1;
  42. c:=random(15);
  43. Setcolor(c);
  44. Rectangle(s1,t,getmaxx-s1,getmaxy-t);
  45. delay(50);
  46. until(n=5);
  47. SetColor(15);
  48. Bar(50,90,GetMaxX-50,300);
  49. MoveTo(80,GetMaxY div 3);
  50. SetTextStyle(1,0,5);
  51. OutText('Worms, Worms, Worms');
  52. SettextStyle(0,0,2);
  53. OutTextXY(getmaxx div 3 ,getmaxy div 2,'Начнем !!!');
  54. readLn;
  55. SetColor(0);
  56. SetBkColor(0);
  57. CloseGraph;
  58. ClrScr;
  59. SetNoCursor;
  60. GotoXy(15,5);
  61. Write('Введите скорость от 1-20 (чем больше ,тем медленнее): ');
  62. ReadLn(speed);
  63. if speed > 20 then
  64. begin
  65. GoToXY(20,6);
  66. Write('Скорость слишком маленькая, введите еще раз: ');
  67. Read(speed);
  68. end;
  69. ClrScr;
  70. TextColor(9);
  71. Write(chr(201));
  72. GotoXy(50,1);
  73. Write(chr(187));
  74. for top:=2 to 49 do
  75. begin
  76. GotoXY(top,1);
  77. write(chr(205));
  78. end;
  79. for right:=2 to 24 do
  80. begin
  81. GotoXy(1,right);
  82. Write(chr(186));
  83. GotoXy(50,right);
  84. Write(chr(186));
  85. end;
  86. GotoXY(1,24);
  87. Write(chr(200));
  88. GotoXY(50,24);
  89. Write(chr(188));
  90. for top:=2 to 49 do
  91. begin
  92. GotoXy(top,24);
  93. Write(chr(205));
  94. end;
  95. { for i:=0 to 2000 do begin
  96. x[i]:=0;
  97. y[i]:=0;
  98. end;}
  99. x[1]:=35;
  100. y[1]:=10;
  101. Randomize;
  102. repeat
  103. c:=random(16);
  104. TextColor(c);
  105. Gotoxy(Random(79),random(24));
  106. xx:=WhereX;
  107. xy:=WhereY;
  108. Until(xx<>x[1]) and (xy<>x[1]) and (c<>0) and (xx>1) and (xy>1) and (xx<49) and (xy<24);
  109. Write('X');
  110. xb:=x[1]; xe:=x[1];
  111. yb:=y[1]; ye:=y[1];
  112. l:=1;
  113. score:=0;
  114. GotoXY(xb,yb);
  115. Write('[');
  116. GotoXY(51,2);
  117. Write('Длина червя = ',l);
  118. GotoXY(51,4);
  119. Write('Скорость червя = ',speed);
  120. GoToXY(51,6);
  121. Write('Кол-во очков = ',score);
  122. repeat
  123. ch:=readkey;
  124. ch:=readkey;
  125. if ch =#77 then
  126. begin
  127. repeat
  128. if e=2 then
  129. begin
  130. sound(150);
  131. delay(1000);
  132. Nosound;
  133. Exit;
  134. end;
  135. e:=1;
  136. xb:=x[1]+1;
  137. if xb=50 then
  138. begin
  139. sound(150);
  140. delay(1000);
  141. Nosound;
  142. Exit;
  143. end;
  144. if not((xb-1=xx) and (yb=xy)) then
  145. begin
  146. Gotoxy(xe,ye);
  147. Write(' ');
  148. end
  149. else
  150. begin
  151. l:=l+1;
  152. f:=l;
  153. score:=score+5;
  154. GotoXY(51,2);
  155. Write('Длина червя = ',l);
  156. if f in [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200] then speed:=Speed+1;
  157. {(l=10) or (l=20) or (l=30) or (l=40) or (l=50) or (l=60) or (l=70) or (l=80)}
  158. if speed=21 then
  159. begin
  160. ClrScr;
  161. Gotoxy(40,12);
  162. Write('ВЫ ВЫИГРАЛИ');
  163. end;
  164. GotoXY(51,4);
  165. Write('Скорость червя = ',speed);
  166. GoToXY(51,6);
  167. Write('Кол-во очков = ',score);
  168. repeat
  169. c:=random(16);
  170. TextColor(c);
  171. Gotoxy(Random(80),random(25));
  172. xx:=WhereX;
  173. xy:=WhereY;
  174. Until(xx<>x[1]) and (xy<>y[1]) and (c<>0) and (xx>1) and (xy>1) and (xx<49) and (xy<24);
  175. Write('X');
  176. end;
  177. repeat
  178. c:=random(15);
  179. TextColor(c);
  180. until(c<>0);
  181. Gotoxy(xb,yb);
  182. Write ('O');
  183. delay(1000+round(1/speed*220));
  184. For i:=l downto 1 do
  185. begin x[i]:=x[i-1];y[i]:=y[i-1];
  186. end;
  187. x[1]:=xb;y[1]:=yb;
  188. xe:=x[l];ye:=y[l];
  189. for i:=2 to l do
  190. if (xb = x[i]) and (yb = y[i]) then Exit;
  191. until(keypressed);
  192. end;
  193. if ch =#75 then
  194. begin
  195. repeat
  196. xb:=x[1]-1;
  197. if e=1 then
  198. begin
  199. sound(150);
  200. delay(1000);
  201. Nosound;
  202. Exit;
  203. end;
  204. e:=2;
  205. if xb=1 then
  206. begin
  207. sound(150);
  208. delay(1000);
  209. Nosound;
  210. Exit;
  211. end;
  212. if not((xb+1=xx) and (yb=xy)) then
  213. begin
  214. Gotoxy(xe,ye);
  215. Write(' ');
  216. end
  217. else
  218. begin
  219. l:=l+1;
  220. f:=l;
  221. score:=score+5;
  222. GotoXY(51,2);
  223. Write('Длина червя = ',l);
  224. if f in [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200]
  225. {(l=10) or (l=20) or (l=30) or (l=40) or (l=50) or (l=60) or (l=70) or (l=80)} then speed:=Speed+1;
  226. if speed=21 then
  227. begin
  228. ClrScr;
  229. Gotoxy(40,12);
  230. Write('ВЫ ВЫИГРАЛИ');
  231. end;
  232. GotoXY(51,4);
  233. Write('Скорость червя = ',speed);
  234. GoToXY(51,6);
  235. Write('Кол-во очков = ',score);
  236. repeat
  237. c:=random(16);
  238. TextColor(c);
  239. Gotoxy(Random(80),random(25));
  240. xx:=WhereX;
  241. xy:=WhereY;
  242. Until(xx<>x[1]) and (xy<>x[1]) and (c<>0) and (xx>1) and (xy>1) and (xx<49) and (xy<24);
  243. Write('X');
  244. end;
  245. repeat
  246. c:=random(15);
  247. TextColor(c);
  248. until(c<>0);
  249. Gotoxy(xb,yb);
  250. Write ('O');
  251. delay(1000+round(1/speed*220));
  252. For i:=l downto 1 do
  253. begin x[i]:=x[i-1];
  254. y[i]:=y[i-1];
  255. end;
  256. x[1]:=xb; y[1]:=yb;
  257. xe:=x[l]; ye:=y[l];
  258. for i:=2 to l do
  259. if (xb = x[i]) and (yb = y[i]) then Exit;
  260. until(keypressed);
  261. end;
  262. if ch =#80 then
  263. begin
  264. if e = 4 then
  265. begin
  266. sound(150);
  267. delay(1000);
  268. Nosound;
  269. Exit;
  270. end;
  271. e:=3;
  272. repeat
  273. yb:=y[1]+1;
  274. if yb=24 then
  275. begin
  276. sound(150);
  277. delay(1000);
  278. Nosound;
  279. Exit;
  280. end;
  281. if not((xb=xx) and (yb-1=xy)) then
  282. begin
  283. Gotoxy(xe,ye);
  284. Write(' ');
  285. end
  286. else
  287. begin
  288. l:=l+1;
  289. f:=l;
  290. score:=score+5;
  291. GotoXY(51,2);
  292. Write('Длина червя = ',l);
  293. if f in [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200]
  294. {(l=10) or (l=20) or (l=30) or (l=40) or (l=50) or (l=60) or (l=70) or (l=80)} then speed:=Speed+1;
  295. if speed=21 then
  296. begin
  297. ClrScr;
  298. Gotoxy(40,12);
  299. Write('ВЫ ВЫИГРАЛИ');
  300. end;
  301. GotoXY(51,4);
  302. Write('Скорость червя = ',speed);
  303. GoToXY(51,6);
  304. Write('Кол-во очков = ',score);
  305. repeat
  306. c:=random(16);
  307. TextColor(c);
  308. Gotoxy(Random(80),random(25));
  309. xx:=WhereX;
  310. xy:=WhereY;
  311. Until(xx<>x[1]) and (xy<>x[1]) and (c<>0) and (xx>1) and (xy>1) and (xx<49) and (xy<24);
  312. Write('X');
  313. end;
  314. repeat
  315. c:=random(15);
  316. TextColor(c);
  317. until(c<>0);
  318. Gotoxy(xb,yb);
  319. Write ('O');
  320. delay(1000+round(1/speed*220));
  321. For i:=l downto 1 do
  322. begin x[i]:=x[i-1];y[i]:=y[i-1];end;
  323. x[1]:=xb;y[1]:=yb;
  324. xe:=x[l];ye:=y[l];
  325. y[1]:=yb;
  326. for i:=2 to l do
  327. if (xb = x[i]) and (yb = y[i]) then Exit;
  328. until(keypressed);
  329. end;
  330. if ch =#72 then
  331. begin
  332. if e = 3 then
  333. begin
  334. sound(150);
  335. delay(1000);
  336. Nosound;
  337. Exit;
  338. end;
  339. repeat
  340. e:=4;
  341. yb:=y[1]-1;
  342. if yb=1 then
  343. begin
  344. sound(150);
  345. delay(2000);
  346. Nosound;
  347. Exit;
  348. end;
  349. if not((xb=xx) and (yb+1=xy)) then
  350. begin
  351. Gotoxy(xe,ye);
  352. Write(' ');
  353. end
  354. else
  355. begin
  356. l:=l+1;
  357. score:=score+5;
  358. GotoXY(51,2);
  359. Write('Длина червя = ',l);
  360. if f in [10,20,30,40,50,60,70,80,90,100,110,120,130,140,150,160,170,180,190,200]
  361. {(l=10) or (l=20) or (l=30) or (l=40) or (l=50) or (l=60) or (l=70) or (l=80)} then speed:=Speed+1;
  362. if speed=21 then
  363. begin
  364. ClrScr;
  365. Gotoxy(40,12);
  366. Write('ВЫ ВЫИГРАЛИ');
  367. end;
  368. GotoXY(51,4);
  369. Write('Скорость червя = ',speed);
  370. GoToXY(51,6);
  371. Write('Кол-во очков = ',score);
  372. repeat
  373. c:=random(16);
  374. TextColor(c);
  375. Gotoxy(Random(80),random(25));
  376. xx:=WhereX;
  377. xy:=WhereY;
  378. Until(xx<>x[1]) and (xy<>x[1]) and (c<>0) and (xx>1) and (xy>1) and (xx<49) and (xy<24);
  379. Write('X');
  380. end;
  381. repeat
  382. c:=random(15);
  383. TextColor(c);
  384. until(c<>0);
  385. Gotoxy(xb,yb);
  386. Write ('O');
  387. delay(1000+round(1/speed*220));
  388. For i:=l downto 1 do
  389. begin x[i]:=x[i-1];y[i]:=y[i-1];end;
  390. x[1]:=xb;y[1]:=yb;
  391. xe:=x[l];ye:=y[l];
  392. y[1]:=yb;
  393. for i:=2 to l do
  394. if (xb = x[i]) and (yb = y[i]) then Exit;
  395. until(keypressed);
  396. end;
  397. until(ch=#3);
  398. end.