049 } gotoxy(x,y);
050 } write(sym);
051 } gotoxy(1,1);
052 } End;
{------------------------------------------------------}
053 } Procedure Rezultat(var d:res;scr,dl:integer);
054 } var f1:result;
055 } Begin
056 } {$I-}
057 } Reset(d);
058 } {$I+}
059 } IF IOResult<>0 THen rewrite(d);
060 } clrscr;
061 } gotoxy(28,22);
062 } textcolor(green);
063 } write('Введить ваше iм`я: ');
064 }readln(f1.name);
065 } f1.scor:=scr;
066 } f1.len:=dl;
067 } seek(d,filesize(d));
068 } write(d,f1);
069 } Close(d);
070 } Textcolor(0);
071 } Halt;
072 } End;
{--------------------------------------------------------}
073 } Procedure OverRes(var d:res);
074 } var f1:result;
075 } y:integer;
076 } Begin
077 } ClrScr;
078 } {$I-}
079 } Reset(d);
080 } {$I+}
081 } IF IOResult<>0 THEN begin
082 } gotoxy(28,22);
083 } textcolor(green);
084 }write('Результатiв немає!');end
085 }Else
086 } begin
087 } textcolor(green);
088 } y:=1;
089 } while not eof(d) do begin
090 } read(d,f1);
091 } gotoxy(1,y); write('Iм`я: ',f1.name);
092 } gotoxy(30,y); write('Довжина: ',f1.len);
093 } gotoxy(45,y); write('Oчки: ',f1.scor:5);
094 } y:=y+1;
095 } end;
096 } Close(d);
097 } end;
098 } repeat until keypressed;
099 } textcolor(0);
100}End;
{-------------------------------------------------------------------}
101 } Procedure GoUp(x,y:integer);
102 } Begin
103 } Ramka(x,y);
104 } MenuSelect:=Menuselect-1;
105 } IF MenuSelect < 1 THEN MenuSelect:=6;
106 } TextColor(14);
107 } TextBackground(0);
108 } GotoXY(x+1,y+MenuSelect);
109 } write(MenuItem[MenuSelect]);
110 } Textbackground(0);
111 } textcolor(0);
112 } gotoxy(1,1);
113 } End;
{------------------------------------------------------}
114 }Procedure GoDown(x,y:integer);
115 }Begin
116 }ramka(x,y);
117 }MenuSelect:=MenuSelect+1;
118 }IF MenuSelect > 6 THEN MenuSelect:=1;
119 }textcolor(14);
120 }textbackground(0);
121 }gotoxy(x+1,y+MenuSelect);
122 }write(MenuItem[MenuSelect]);
123 }textcolor(0);
124 }textbackground(0);
125 }gotoxy(x,y);
126 }End;
{------------------------------------------------------}
127 }Procedure Menu;
128 }label b;
129 }Var
130 }X,Y,I:integer;
131 }Begin
132 }b:
133 }dlina:=5;
134 }Naprav:=1;
135 }HeadX:=5;
136 }HeadY:=1;
137 }Score:=0;
138 }X:=28;Y:=20;
139 }clrscr;
140 }Ramka(x,y);
141 }textcolor(14);
142 }textbackground(0);
143 }gotoxy(x+1,y+Menuselect);
144 }write(MenuItem[MenuSelect]);
145 }textcolor(0);
146 }textbackground(0);
147 }gotoxy(1,1);
148 }repeat
149 }I:=ord(readkey);
150 }case I of
151 }72:GoUp(x,y);
152 }80:GoDown(x,y);
153 }end;
154 }Until (I=27)or(I=13);
155 }IF i=27 THEN halt;
156 }Case MenuSelect of
157 }1: Begin
DTime:=10000;
ScorePlus:=5;
End;
158 }2: Begin
DTime:=8000;
ScorePlus:=10;
End;
159 }3: Begin
DTime:=6000;
ScorePlus:=15;
End;
160 }4: Begin
DTime:=4000;
ScorePlus:=20;
End;
161 }5: Begin
DTime:=2000;
ScorePlus:=25;
End;
162 }6: Begin
OverRes(f);
ClrScr;
goto b;
End;
163 }End;
164 }CLRSCR;
165 }End;
{---------------------------------------------------------}
166 }Procedure DrawSnake;
167 }Begin
168 }textcolor(15);
169 }gotoxy(1,50);
170 }write(' ');
171 }gotoxy(1,50);
172 }write('Oчки: ',Score);
173 }gotoxy(20,50);
174 }write('Програму разрoбив Матковський Руслан aka Pat');
175 }gotoxy(65,50);
176 }write(' ');
177 }gotoxy(65,50);
178 }write('Довжина: ',Dlina);
179 }Symbol(SnakeX[1],SnakeY[1],chr(15));
180 }textcolor(2);
181 }for i:=2 to Dlina do begin
182 }Symbol(SnakeX[i],SnakeY[i],chr(15));
183 }end;
184 }textcolor(red);
185 }for i:=1 to 40 do
186 }Symbol(BonusX[i],BonusY[i],chr(64));
187 }textcolor(0);
188 }gotoxy(1,1);
189 }End;
{----------------------------------------------------------}
190 }Procedure AddBonus(b:longint);
191 }label 1;
192 }var
193 }Err,f:integer;
194 }Begin
195 }1:
196 }Err:=0;
197 }BonusX[b]:=Random(78)+1;
198 }BonusY[b]:=Random(48)+1;
199 }For f:=1 to 40 do
200 }if f<>b THEN
201 }if ((BonusX[f]=BonusX[b]) and (BonusX[f]<>0) and (BonusY[f]=BonusY[b]) and(BonusY[f]<>0)) THEN Err:=1;
202 }For f:=1 to Dlina do
203 }if (SnakeX[f]=BonusX[b]) and (SnakeY[f]=BonusY[b]) THEN Err:=1;
204 }IF Err=1 THEN goto 1;
205 }textcolor(0);
206 }gotoxy(1,1);
207 }End;
{-----------------------------------------------------------}
208 }Procedure Kill;
209 }Var c:array[1..6] of char;
210 }j:integer;
211 }label 1;
212 }Begin
213 }c[1]:='X';
214 }c[2]:='x';
215 }c[3]:=':';
216 }c[4]:='.';
217 }c[5]:='.';
218 }c[6]:=' ';
219 }Textcolor(2);
220 }for i:=1 to 6 do begin
221 }for j:=1 to Dlina do Symbol(SnakeX[j],SnakeY[j],c[i]);
222 }delay(5000);
223 }end;
224 }1:
225 }CLRSCR;
226 }textcolor(15);
227 }gotoxy(1,50);
228 }write(' ');
229 }gotoxy(1,50);
230 }write('Oчки: ',Score);
231 }gotoxy(20,50);
232 }write('Програму разрoбив Матковський Руслан aka Pat');
233 }gotoxy(65,50);
234 }write(' ');
235 }gotoxy(65,50);
236 }write('Довжина: ',Dlina);
237 }textcolor(2);
238 }gotoxy(28,22);
239 }write('╔═══════════════════╗');
240 }gotoxy(28,23);
241 }write('║ ║');
242 }gotoxy(28,24);
243 }write('║ Продовжити(Y/N)? ║');
244 }gotoxy(28,25);
245 }write('║ ║');
246 }gotoxy(28,26);
247 }write('╚═══════════════════╝');
248 }gotoxy(1,1);
249 }key:=readkey;
250 }case key of
251 }'Y','y','Н','н': begin
menu;
for i:=1 to Dlina do
begin
SnakeX[i]:=6-i;
SnakeY[i]:=1;
end;
end;
252 }'N','n','Т','т':Rezultat(f,Score,Dlina);
253 }else goto 1;
254 }end;
255 }textcolor(0);
256 }gotoxy(1,1);
257 }End;
{----------------------------------------------------------}
258 }procedure Move;
259 }begin
260 }Symbol(SnakeX[Dlina],SnakeY[Dlina],' ');
261 }case naprav of
262 }1: begin
HeadX:=HeadX+1;
263 }End;
264 }2: begin
HeadX:=HeadX-1;
265 }end;
266 } 3: begin
HeadY:=HeadY-1;
267 }end;
268 }4: begin
HeadY:=HeadY+1;
269 }end;
270 }end;
271 }if HeadX>80 then HeadX:=1;
272 }if HeadX<1 then HeadX:=80;
273 }if HeadY>49 then HeadY:=1;
274 }if HeadY<1 then HeadY:=49;
275 }for I:=1 to Dlina do
276 }begin
277 }If (HeadX=SnakeX[i])and(HeadY=SnakeY[i]) then kill;
278 }end;
279 }for i:=1 to 40 do
280 }begin
281 }if (HeadX=BonusX[i])and(HeadY=BonusY[i]) then
282 }begin
283 }Dlina:=Dlina+1;
284 }score:=score+ScorePlus;
285 }addbonus(i);
286 }end;
287 }end;
288 }for I:=Dlina downTo 2 do
289 }begin
290 }SnakeX[i]:=SnakeX[i-1];
291 }SnakeY[i]:=SnakeY[i-1];
292 }end;
293 }SnakeX[1]:=HeadX;
294 }SnakeY[1]:=HeadY;
295 }drawsnake;
296 }textcolor (0);
297 }gotoxy( 1,1);
298 }end;
{-----------------------------------------------------------------}
299 }BEGIN
300 }Assign(f,'result.dat');
301 }Textmode(c80 + Font8x8);
302 }randomize;
303 }CLRSCR;
304 }for i:=1 to 40 do addbonus(i);
305 }MenuItem[1]:=' VERY SLOW ';
306 }MenuItem[2]:=' SLOW ';
307 }MenuItem[3]:=' MEDIUM ';
308 }MenuItem[4]:=' HIGH ';
309 }MenuItem[5]:=' VERY HIGH ';
310 }MenuItem[6]:=' RESULT ';
311 }MenuSelect:=1;
312 }clrscr;
313 }menu;
314 }for i:=1 to Dlina do
315 }begin
316 }SnakeX[i]:=6-i;
317 }SnakeY[i]:=1;
318 }end;
319 }1:
320 }while key<>#27 do
321 }begin
322 }if KeyPressed then
323 }begin
324 }key:=readkey;
325 }if key=#0 then
326 }case readkey of
#72: if Naprav <> 4 then Naprav := 3;{Down}
#80: if Naprav <> 3 then Naprav := 4;{up}
#75: if Naprav <> 1 then Naprav := 2;{Left}
#77: if Naprav <> 2 then Naprav := 1;{Rigth}
327 }end;
328 }end;
329 }textcolor (0);
330 }gotoxy(1,1);
331 }DELAY(DTime);
332 }Move;
333 }textcolor (0);
334 }gotoxy( 1,1);
335 }end;
336 }kill;
337 }goto 1;
338 }close(f);
339 }end.