program laba12_15 uses graph crt const step 10 type kolo object word b

 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
program laba12_15;
uses graph,crt;
const step=10;
type kolo= object
r,x,y:word;
c:byte;
procedure init(x0,y0,r0:word;c0:byte);
procedure move(direction:byte); {0 /\ ; 1 \/ ; 2 < ; 3 > }
end;
procedure kolo.init;
begin
x:=x0;
y:=y0;
r:=r0;
c:=c0;
setcolor(c);
circle(x,y,r);
end;
procedure kolo.move;
begin
setcolor(0);
circle(x,y,r);
case direction of
0: if (y-step>r) then y:=y-step;
1: if (y+step+r<getmaxY) then y:=y+step;
2: if (x-step>r) then x:=x-step;
3: if (x+step+r<getmaxX) then x:=x+step;
end;
setcolor(c);
circle(x,y,r);
end;
var gd,gm:integer;
c1,c2:char;
a:kolo;
begin
initgraph(gd,gm,'d:\tpascal.71\bgi');
a.init(200,200,50,2);
repeat
c1:=readkey;
if c1<>#0 then c2:=#0
else c2:=readkey;
case c2 of
#72: {^} a.move(0);
#80: {v} a.move(1);
#75: {<} a.move(2);
#77: {>} a.move(3);
end;
until (c1=#13{enter}) or (c1=#27{esc}) ;
end.end.