unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Image1: TImage;
Timer1: TTimer;
Timer2: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
public
end;
var
Form1: TForm1;
mx, my, r, vx, vy : integer;
mx1 : array[0..19] of integer;
my1 : array[0..19] of integer;
r1 : array[0..19] of integer;
vx1 : array[0..19] of integer;
vy1 : array[0..19] of integer;
c : integer;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.enabled := true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
timer1.enabled := false;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
doublebuffered := true;
mx := 10;
my := 10;
r := 10;
vx := 1;
vy := 1;
timer1.enabled := false;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
with image1.canvas do begin
pen.color := clblack;
brush.color := clblack;
ellipse(mx-r, my-r, mx+r, my+r);
mx:=mx+vx;
my:=my+vy;
pen.color:=clred;
brush.color:=clred;
ellipse(mx-r, my-r, mx+r, my+r);
end;
if my+r>=image1.height
then vy:= -vy;
if mx+r>=image1.width
then vx:=-vx;
if my-r<0
then vy:=-vy;
if mx-r<0
then vx:=-vx;
for c := 0 to 19 do begin
mX1[c] := random(image1.width);
mY1[c] := random(image1.height);
R1[c] := 10;
vX1[c] := 1;
vY1[c] := 1;
image1.canvas.ellipse(mx1[c]-r1[c], my1[c] - r1[c], mx1[c] + r1[c], my1[c]+r1[c]);
end;
end;
end.