unit uhaupt;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls;
type
TForm1 =
class(TForm)
btn_start: TButton;
btn_ende: TButton;
Shape2: TShape;
sh_kreis: TShape;
Timer1: TTimer;
procedure btn_endeClick(Sender: TObject);
procedure btn_startClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure bewegung;
procedure richtungoben(zahl:integer);
procedure richtunglinks(zahl:integer);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
oben,links:integer;
implementation
{$R *.DFM}
procedure TForm1.btn_endeClick(Sender: TObject);
begin
Close;
end;
procedure TForm1.btn_startClick(Sender: TObject);
begin
bewegung;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
randomize;
oben:=1;
links:=1;
end;
procedure bewegung;
begin
Form1.sh_kreis.Top:=Form1.sh_kreis.Top + (oben);
Form1.sh_kreis.Left:=Form1.sh_kreis.Left + (links);
if Form1.sh_kreis.Top = 456
then
begin
richtungoben(-6);
end;
if Form1.sh_kreis.Top = 8
then
begin
richtungoben(+1);
end;
if Form1.sh_kreis.Left = 8
then
begin
richtunglinks(+1);
end;
if Form1.sh_kreis.Left = 784
then
begin
richtunglinks(-6);
end;
end;
procedure richtungoben(zahl:integer);
begin
oben:=random(5)+zahl;
end;
procedure richtunglinks(zahl:integer);
begin
links:=random(5)+zahl;
end;
end.