u škloi imamo zadatak napraviti njihalo koje bi nakon nekog vremena zbog nekog otpora trebalo prestati sa njihanjem, ja sam napravio njihalo ali ne znam kako ga nakon nekog vremena zaustaviti. molim pomoć!!!
unaprijed zahvaljujem
ovo sam do sad napravio
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
x0:real=320;
y0:real=240;
alfa:real=(pi/6);
l:real=3;
ex:real=60;
ey:real=60;
deltaalfa:real=-0.1;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
form1.Canvas.Pen.Color:=clbtnface;
form1.canvas.moveto(trunc(x0),trunc(y0));
form1.Canvas.lineto(trunc(x0-l*sin(alfa)*ex),trunc(y0+l*cos(alfa)*ey));
form1.canvas.Ellipse(trunc(x0-l*sin(alfa)*ex-5),trunc(y0+l*cos(alfa)*ey-5),trunc(x0-l*sin(alfa)*ey+5),trunc(y0+l*cos(alfa)*ey+5));
alfa:=alfa+deltaalfa;
if (alfa<(-pi/3)) or (alfa>(pi/3)) then
alfa:=alfa-0.01;
deltaalfa:=-deltaalfa;
form1.Canvas.Pen.Color:=clblue;
form1.canvas.moveto(trunc(x0),trunc(y0));
form1.Canvas.lineto(trunc(x0-l*sin(alfa)*ex),trunc(y0+l*cos(alfa)*ey));
form1.canvas.Ellipse(trunc(x0-l*sin(alfa)*ex-5),trunc(y0+l*cos(alfa)*ey-5),trunc(x0-l*sin(alfa)*ey+5),trunc(y0+l*cos(alfa)*ey+5));
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
end;
end.