unit UHA;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TBall =
class
x,y,r,vx,vy:integer;
color:TColor;
procedure init(aX,aY,aVX,aVY,aR:Integer;acolor:TColor);
procedure move;
end;
type
TForm1 =
class(TForm)
Timer1: TTimer;
PaintBox1: TPaintBox;
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
Basketball:TBall;
implementation
{$R *.dfm}
procedure Tball.move;
begin
Form1.PaintBox1.Canvas.Brush.Color:=clwhite;
Form1.PaintBox1.Canvas.Pen.color:=clwhite;
Form1.PaintBox1.Canvas.Ellipse(x-r,y-r,x+r,y+r);
//<-- und hier.danach isses immer wieder hier bis ich neu starte
x:=x+vx;
y:=y+vy;
Form1.PaintBox1.Canvas.brush.Color:=color;
Form1.PaintBox1.Canvas.pen.color:=color;
Form1.PaintBox1.Canvas.ellipse(x-r,y-r,x+r,y+r);
end;
procedure TBall.init(aX,aY,aVX,aVY,aR:Integer;acolor:TColor);
begin
Create;
x:=aX;
y:=aY;
vx:=aVX;
vy:=aVY;
r:=aR;
color:=acolor;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
// Intervall=5
begin
Basketball.move;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Basketball.init(50,50,3,-4,10,
RGB(255,255,0));
end;
//<---HIER zuerst
procedure TForm1.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Basketball.Free;
end;
end.