unit Unit1;
Interface
Uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls,
StdCtrls;
Type TForm1 =
Class(TForm)
Timer1: TTimer;
Image1: TImage;
BStop: TButton;
Timer2: TTimer;
BStart: TButton;
Timer3: TTimer;
Timer4: TTimer;
Procedure Timer1Timer(Sender: TObject);
procedure BStartClick(Sender: TObject);
procedure BStopClick(Sender: TObject);
procedure Zeichne(x,y,DeltaX,Deltay:integer; Farbe:tColor);
procedure AendereOrt(
var x,y,DeltaX,Deltay:integer);
private
x1,y1,DeltaX1,Deltay1,
x2,y2,DeltaX2,Deltay2,
x3,y3,DeltaX3,Deltay3,
x4,y4,DeltaX4,Deltay4: integer;
Farbe1,Farbe2,Farbe3,Farbe4, TischFarbe: tColor;
start:boolean;
End;
Var Form1: TForm1;
Implementation
{$R *.dfm}
procedure TForm1.AendereOrt(
var x,y,DeltaX,Deltay:integer);
begin
If x < 10
Then DeltaX := -DeltaX
Else If x >= Image1.Width - 80
Then DeltaX := -DeltaX;
If y < 10
Then Deltay := -DeltaY
Else If y >= Image1.Height - 80
Then Deltay := -DeltaY;
x:=x+DeltaX;
y:=y+Deltay;
end;
procedure TForm1.Zeichne(x,y,DeltaX,Deltay:integer; Farbe:tColor);
begin
x:=x+DeltaX;
y:=y+Deltay;
Image1.Canvas.Ellipse(x,y,x+50,y+50);
end;
Procedure TForm1.Timer1Timer(Sender: TObject);
Begin
Zeichne(x1,y1,DeltaX1,DeltaY1, Farbe1);
Zeichne(x2,y2,DeltaX2,DeltaY2, Farbe2);
Zeichne(x3,y3,DeltaX3,DeltaY3, Farbe3);
Zeichne(x4,y4,DeltaX4,DeltaY4, Farbe4);
End;
procedure TForm1.BStartClick(Sender: TObject);
begin
start:=true;
TischFarbe:=clgreen;
x1:=100 ;
y1:=100 ;
DeltaX1:=10;
DeltaY1:=10;
Farbe1:=clBlack;
x2:=250 ;
y2:=400 ;
DeltaX2:=5;
DeltaY2:=5 ;
Farbe2:=clyellow;
x3:=120 ;
y3:=220 ;
DeltaX3:=15;
DeltaY3:=15;
Farbe3:=clBlue;
x4:=20 ;
y4:=140 ;
DeltaX4:=20;
DeltaY4:=20 ;
Farbe4:=clfuchsia;
end;
procedure TForm1.BStopClick(Sender: TObject);
begin
start:=false;
end;
end.