unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
procedure Button1Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
MannX: Integer;
MannY: Integer;
JagdX: Integer;
JagdY: Integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Visible := false;
Button2.Visible := true;
Button3.Visible := true;
Button4.Visible := true;
Button5.Visible := true;
Canvas.Brush.Color := clred;
Form1.Canvas.Rectangle(MannX,MannY,MannX+50,MannY+50);
Form1.Canvas.Rectangle(JagdX,JagdY,JagdX+50,JagdY+50);
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
//links
dec(MannX,5);
Form1.Refresh;
Canvas.Rectangle(MannX,MannY,MannX + 50,MannY+50);
JagdX:=random(40)+1;
JagdY:=random(40)+1;
Form1.Canvas.Rectangle(JagdX,JagdY,JagdX+50,JagdY+50);
If (MannX+50>JagdX)
and (MannX<JagdX+50)
or (MannY<JagdY+50)
and (MannÝ+50>JagdY)
then (Form1.Canvas.Rectangle(JagdX,JagdY,JagdX+50,JagdY+50))
and(JagdX:=random(400)+1)
and
(JagdY:=random(400)+1);
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
//rechts
inc(MannX,5);
Form1.Refresh;
Canvas.Rectangle(MannX,MannY,MannX + 50,MannY+50);
JagdX:=random(40)+1;
JagdY:=random(40)+1;
Form1.Canvas.Rectangle(JagdX,JagdY,JagdX+50,JagdY+50);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
//hoch
dec(mannY,5);
Form1.Refresh;
Canvas.Rectangle(MannX,MannY,MannX + 50,MannY+50);
JagdX:=random(40)+1;
JagdY:=random(40)+1;
Form1.Canvas.Rectangle(JagdX,JagdY,JagdX+50,JagdY+50);
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
//runter
inc(MannY,5);
Form1.Refresh;
Canvas.Rectangle(MannX,MannY,MannX + 50,MannY+50);
JagdX:=random(40)+1;
JagdY:=random(40)+1;
Form1.Canvas.Rectangle(JagdX,JagdY,JagdX+50,JagdY+50);
end;
end.