1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
| Uses crt, graphABC, events,timers;
type
TDirection = (None, Left, Right, Up, Down);
const
r=15 ;
B=20;
d=8;
Var
i, a: integer;
s: string[63];
k: char;
x,t,y,z,xr,yr,prin1,prin2,prin3,prin4,prin5,g,s4et,prin6: integer;
Direction :TDirection;
xs,ys,bufx,bufy:array[1..200]of integer;
Procedure BuildMenu;
Const
l: array[1..5] of string[5] = (
'Easy','Medium','Hard', 'About', 'Exit');
Begin
ClrScr;
//cursoroff;
For i := 1 to 5 do
begin
If i = a then
TextColor(Red)
Else TextColor(Black);
gotoxy(44,10+i);
WriteLn(l[i]);
end;
End;
procedure shar3;
begin
SetBrushColor(clYellow);
circle(xs[g],ys[g],r);
end;
procedure Circl;
begin
SetBrushColor(clred);
circle(x,y,B);
end;
procedure rshar ;
begin
xr:=Random(WindowWidth) ;
yr:=Random( WindowHeight);
end;
procedure rshar2;
begin
SetBrushColor(clgreen);
circle(xr,yr,r);
end;
procedure XP(Key:integer);
begin
case Key of
VK_Left: Direction := Left ;
VK_Right:Direction := Right ;
VK_UP: Direction := UP ;
VK_Down: Direction :=Down ;
end;
circle(x,y,r);
end;
procedure pause;
begin
SetWindowSize(640,480);
for i:=1 to 1 do
begin
Circl;
rshar2;
ClearWindow;
rshar2 ;
prin1:=(xr-x+r)*(xr-x+r)+(yr-y)*(yr-y) ;
prin2:=(xr-x-r)*(xr-x-r)+(yr-y)*(yr-y) ;
prin3:=(xr-x)*(xr-x)+(yr-y+r)*(yr-y+r) ;
prin4:=(xr-x)*(xr-x)+(yr-y-r)*(yr-y-r) ;
prin5:=R*R;
if (prin1)<=(prin5) then begin
rshar ;
s4et:=s4et+1;
end;
if (prin2)<=(prin5) then begin
rshar ;
s4et:=s4et+1;
end;
if (prin3)<=(prin5) then begin
rshar ;
s4et:=s4et+1;
end;
if (prin4)<=(prin5) then begin
rshar ;
s4et:=s4et+1;
end;
case Direction of
Left: begin x:=x-d; if x<=0 then x:=WindowWidth end;
Up: begin y:=y-d; if y<=0 then y:=WindowHeight end;
Right: begin x:=x+d; if x>=WindowWidth then x:=0 end;
Down: begin y:=y+d; if y>=WindowHeight then y:=0 end;
end;
xs[1]:=x;
ys[1]:=y;
for g:=1 to s4et do
begin
bufx[g]:=xs[g];
bufy[g]:=ys[g];
end;
for g:=1 to s4et do
begin
xs[g+1]:=bufx[g];
ys[g+1]:=bufy[g] ;
end;
for g:=2 to s4et do
shar3;
Circl;
end;
end;
Procedure Easy;
begin
rshar;
s4et:=2;
Direction := None;
x:=WindowWidth div 2;
y:=WindowHeight div 2;
OnKeyDown:=XP;
t:=CreateTimer(70, pause);
end;
Procedure Medium;
begin
rshar;
s4et:=2;
Direction := None;
x:=WindowWidth div 2;
y:=WindowHeight div 2;
OnKeyDown:=XP;
t:=CreateTimer(50, pause);
end;
Procedure Hard;
begin
rshar;
s4et:=2;
Direction := None;
x:=WindowWidth div 2;
y:=WindowHeight div 2;
OnKeyDown:=XP;
t:=CreateTimer(25, pause);
end;
Procedure About;
Begin
clrscr;
Textcolor(Red);
Gotoxy(18,4);
Write(' Óðàëüñêèé ôåäåðàëüíûé óíèâåðñèòåò èì. Á.Í. Åëüöèíà');
Gotoxy(20,5);
Write('Êàôåäðà Âîäîñíàáæåíèÿ è Âîäîîòâåäåíèÿ');
Gotoxy(12,16);
Write('Êóðñîâàÿ ðàáîòà');
Gotoxy(12,17);
Write('Ïî èíôîðìàòèêå');
Gotoxy(12,18);
Write('15-ãðàííèê');
Gotoxy(12,19);
Write('Ãðóïïà: CÒ-140013');
Gotoxy(12,20);
Write('Ñòóäåíò: Ãóáà Íàòàëèÿ "Êàêàÿ-òî"-âíà (äîïèøè ñâî¸ îò÷åñòâî)');
Gotoxy(30,25);
Write('ã.Åêàòåðèíáóðã 2015 ã.');
Readln;
writeln('Press <SPACE> to quit.');
while true do
begin
k:=readkey;
if k=#32 then
exit;
end;
End;
{------------------------------------------------}
Begin
SetWindowWidth(768);
SetWindowHeight(576);
a := 1;
BuildMenu;
Repeat
k := ReadKey;
If k = #0 then begin
k := ReadKey;
Case k of
#72: begin
a := a - 1;
If a < 1 then a := 5;
end;
#80: begin
a := a + 1;
If a > 5 then a := 1;
end;
end;
end
Else
begin
If k = #13 then
Case a of
1: Easy;
2: Medium;
3: Hard;
4: About;
5: Exit;
end;
end;
BuildMenu;
Until k = #27;
End. |