unit pongu;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls;
type
TForm1 =
class(TForm)
Timer1: TTimer;
BitBtn1: TBitBtn;
Edit1: TEdit;
Edit2: TEdit;
Label1: TLabel;
Label2: TLabel;
PaintBox1: TPaintBox;
procedure BitBtn1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Var winkel,r :REAL ;
dx,dy : INTEGER ;
implementation
{$R *.dfm}
procedure TForm1.Button1.Click(Sender: TObject);
begin
timer1.enabled:= true ;
end;
VAR a : Tbitmap;
procedure TForm1.FormCreate(Sender: TObject);
begin
a := Tbitmap.create;
a.loadfromfile ('
H:\ball.bmp');
PaintBox1.canvas.draw (i+dx,i+dy,a);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
a.free;
end;
VAR i : INTEGER ;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
i := 1 ;
winkel := strtofloat (edit1.text);
r := strtofloat (edit2.text);
dx := round(cos(winkel*PI/180) *r) ;
dy := round (sin(winkel*PI/180) *r) ;
Form1.Repaint:
i := i+1 ;
end;
end.