Все просто: смещение качелей по координате X=sin(t), по координате Y=1-cos(sin(t)). Не забыть еще что Y вниз идет при рисовании.
Код
program kach;
uses Crt,Graph;
procedure DrawFon; {рисуем фон}
begin
setfillstyle(9,blue);
bar(0,0,640,75);
setcolor(14);
circle(45,40,30);
setfillstyle(1,14);
floodfill(45,40,14);
setcolor(6);
setlinestyle(0,0,3);
line(200,100,400,100);
line(200,300,200,100);
line(400,300,400,100);
line(260,250,260,100);
line(340,250,340,100);
setfillstyle(1,darkgray);
bar(250,250,350,260);
setfillstyle(1,green);
Bar(0,300,640,360);
setlinestyle(0,0,3);
end;
procedure DrawKach(x,y:integer); {рисуем качели со смещением по x и y}
begin
setcolor(6);
line(260+x,250-y,260,100);
line(340+x,250-y,340,100);
setfillstyle(1,darkgray);
bar(250+x,250-y,350+x,260-y);
end;
procedure DrawNoKach(x,y:integer); {стираем качели со смещением по x и y}
begin
setcolor(0);
line(260+x,250-y,260,100);
line(340+x,250-y,340,100);
setfillstyle(1,black);
bar(250+x,250-y,350+x,260-y);
end;
var driver,mode:integer;
t,h :real;
begin
h:=2*pi/400;
t:=0;
driver:=VGA; mode:=VGAhi;
InitGraph(driver,mode,'C:\BP\BGI');
DrawFon;
repeat
DrawNoKach(trunc(20*(sin(t))),trunc(20*(1-cos(sin(t)))));
t:=t+h;
if t>2*pi then t:=0;
DrawKach(trunc(20*(sin(t))),trunc(20*(1-cos(sin(t)))));
delay(1000);
until keypressed;
CloseGraph;
end.
:smoke: