Ну это вот так:
здесь даже цвет менять можно
Код
uses crt,graph;
var
gd,gm:integer;
x,y,r,metod:integer;
minx,miny,maxx,maxy:integer;
ch:char;
zvetm,zvetgr:integer;
pause:integer;
begin
gd:=detect;
initGraph(gd,gm,'D:bpbgi');
delay(10000);
zvetgr:=1;
x:=320;
y:=240;
metod:=0;
minx:=0;
miny:=0;
maxx:=639;
maxy:=479;
r:=10;
pause:=150;
setcolor(zvetgr);
line(minx,0,minx,480);
line(maxx,0,maxx,480);
line(0,miny,640,miny);
line(0,maxy,640,maxy);
zvetm:=14;
while ch<>#27 do
begin
setcolor(zvetgr);
line(minx,0,minx,480);
line(maxx,0,maxx,480);
line(0,miny,640,miny);
line(0,maxy,640,maxy);
setcolor(zvetm);
circle(x,y,r);
delay(pause);
setcolor(0);
circle(x,y,r);
if (metod=0) then
begin
x:=x+1;
y:=y+1;
end;
if (metod=1) then
begin
x:=x+1;
y:=y-1;
end;
if (metod=2) then
begin
x:=x-1;
y:=y-1;
end;
if (metod=3) then
begin
x:=x-1;
y:=y+1;
end;
if (x<=minx+r+1) and (metod=2) then metod:=1;
if (x<=minx+r+1) and (metod=3) then metod:=0;
if (x>=maxx-r-1) and (metod=1) then metod:=2;
if (x>=maxx-r-1) and (metod=0) then metod:=3;
if (y<=miny+r+1) and (metod=1) then metod:=0;
if (y<=miny+r+1) and (metod=2) then metod:=3;
if (y>=maxy-r-1) and (metod=3) then metod:=2;
if (y>=maxy-r-1) and (metod=0) then metod:=1;
if keypressed then ch:=readkey;
if (ch='+') and (r<230) and ((2*r)<(maxx-minx-5)) and ((2*r)<(maxy-miny-10)) then
begin
r:=r+5;
ch:=#0;
end;
if (ch='-') and (r>10) and ((2*r)<(maxx-minx)) and ((2*r)<(maxy-miny-10)) then
begin
r:=r-5;
ch:=#0;
end;
if (ch='a') and ((minx+10)<maxx) and ((2*r)<(maxx-minx-10)) and (minx<640-2*r) and ((x-r)>minx+10)
then
begin
setcolor(0);
line(minx,0,minx,480);
minx:=minx+10;
setcolor(zvetgr);
line(minx,0,minx,480);
ch:=#0;
end;
if (ch='d') and ((maxx-10)>minx) and ((2*r)<(maxx-minx-10)) and (maxx>2*r) and ((x+r)<maxx-10) then
begin
setcolor(0);
line(maxx,0,maxx,480);
maxx:=maxx-10;
setcolor(zvetgr);
line(maxx,0,maxx,480);
ch:=#0;
end;
if (ch='w') and ((miny+10)<maxy) and ((2*r)<(maxy-miny-10)) and (miny<480-2*r) and ((y-r)>miny+10)
then
begin
setcolor(0);
line(0,miny,640,miny);
miny:=miny+10;
setcolor(zvetgr);
line(0,miny,640,miny);
ch:=#0;
end;
if (ch='x') and ((maxy-10)>miny) and ((2*r)<(maxy-miny-10)) and (maxy>2*r) and ((y+r)<maxy-10) then
begin
setcolor(0);
line(0,maxy,640,maxy);
maxy:=maxy-10;
setcolor(zvetgr);
line(0,maxy,640,maxy);
ch:=#0;
end;
if (ch='8') and (miny>0) then
begin
setcolor(0);
line(0,miny,640,miny);
miny:=miny-10;
setcolor(zvetgr);
line(0,miny,640,miny);
ch:=#0;
end;
if (ch='2') and (maxy<470) then
begin
setcolor(0);
line(0,maxy,640,maxy);
maxy:=maxy+10;
setcolor(zvetgr);
line(0,maxy,640,maxy);
ch:=#0;
end;
if (ch='4') and (minx>0) then
begin
setcolor(0);
line(minx,0,minx,480);
minx:=minx-10;
setcolor(zvetgr);
line(minx,0,minx,480);
ch:=#0;
end;
if (ch='6') and (maxx<630) then
begin
setcolor(0);
line(maxx,0,maxx,480);
maxx:=maxx+10;
setcolor(zvetgr);
line(maxx,0,maxx,480);
ch:=#0;
end;
if (ch=']') and (zvetm<14) then
begin
zvetm:=zvetm+1;
ch:=#0;
end;
if (ch='[') and (zvetm>1) then
begin
zvetm:=zvetm-1;
ch:=#0;
end;
if (ch=',') and (pause>10) then
begin
pause:=pause-10;
ch:=#0;
end;
if (ch='.') and (pause<1000) then
begin
pause:=pause+10;
ch:=#0;
end;
end;
closegraph;
end.