unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Shape1: TShape;
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure Shape1DragDrop(Sender, Source: TObject; X, Y: Integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
x1,x2,y1,y2,i,j:integer;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
begin
image1.Canvas.create;
x1:=20;x2:=50;y1:=20;y2:=50;
image1.canvas.Ellipse(x1,y1,x2,y2);
end;
{begin
image3.Canvas.create;
x1:=20;x2:=50;y1:=20;y2:=50;
image3.canvas.Ellipse(x1,y1,x2,y2);end; }
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
image1.canvas.pen.color:=clwhite;
image1.canvas.Ellipse(x1,y1,x2,y2);
image1.canvas.pen.color:=clfuchsia;
if(x1>=657)
then begin x1:=1; x2:=31;
end;
if(x1<=0)
then begin x1:=627; x2:=657;
end;
if(y1>425)
then begin y1:=0; y2:=30;
end ;
if(y1<0)
then begin y1:=395; y2:=425;
end;
if key=vk_right
then Begin inc(x1);inc(x2); image1.canvas.Ellipse(x1,y1,x2,y2);
end;
if key=vk_left
then Begin dec(x1);
dec(x2);image1.canvas.Ellipse(x1,y1,x2,y2);
end;
if key=vk_up
then Begin dec(y1);
dec(y2); image1.canvas.Ellipse(x1,y1,x2,y2);
end;
if key=vk_down
then Begin inc(y1);inc(y2);image1.canvas.Ellipse(x1,y1,x2,y2);
end;
if (ABS(x1-shape1.left)<=10)
and(abs(y1-shape1.top)<=10)
then showmessage('
getroffen');
if (ABS(x2-shape1.top)<=10)
and(abs(y2-shape1.left)<=10)
then showmessage('
getroffen');
end;
procedure TForm1.Shape1DragDrop(Sender, Source: TObject; X, Y: Integer);
begin
Randomize;
random(shape1.left);
random(shape1.top);
end;
end.