Показать сообщение отдельно
  #4  
Старый 19.08.2008, 12:37
AlexSku AlexSku вне форума
Специалист
 
Регистрация: 07.05.2007
Адрес: Москва
Сообщения: 884
Репутация: 21699
По умолчанию

Код:
type
  TForm1 = class(TForm)
    Shape1: TShape;
    Shape2: TShape;
    Timer1: TTimer;      // интервал 100
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses mmsystem, Math;

{$R *.dfm}
var
  R: Real = 200;
  xc, yc: Integer;

procedure TForm1.FormCreate(Sender: TObject);
begin
  xc:= Shape1.Left + Shape1.Width div 2;
  yc:= Shape1.Top + Shape1.Height div 2;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var 
  t: Real;
  x, y: Extended;
begin
  t:= timeGetTime / 5000.0;
  SinCos(t, y, x);
  Shape2.Left:= Round(x* R) + xc - Shape2.Width div 2;
  Shape2.Top:= Round(y* R) + yc - Shape2.Height div 2;
end;

end.
Ответить с цитированием