unit UFang1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, UPunkte;
type
TFPanel1 =
class(TForm)
BStart: TButton;
ShSpiel: TShape;
Panel: TPanel;
Timer1: TTimer;
procedure BStartClick(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure PanelWeg(Sender:TObject);
procedure FormCreate(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
FPanel1: TFPanel1;
zaehler: integer;
implementation
{$R *.dfm}
procedure TFPanel1.BStartClick(Sender: TObject);
var i: integer;
begin
Timer1.Enabled:= True ;
for i:= 0
to 4
do begin
Panel:= TPanel.Create (FPanel1);
Panel.Color:= clYellow;
Panel.Caption:= '
F';
Panel.Width:= 49;
Panel.Height:= 33;
Panel.Left:= Random(ShSpiel.Width-60)+30;
Panel.Top:= Random(ShSpiel.Height-50)+30;
Panel.Parent:= FPanel1;
Panel.OnClick:= PanelWeg;
end;
Punktefenster:=TPunktefenster.Create(self);
Punktefenster.show;
Punktefenster.MPktAnzeige.Lines.Add(IntToStr(Zaehler)+'
'+'
Punkte');
end;
procedure TFPanel1.FormCreate(Sender: TObject);
begin
randomize;
Zaehler:=5;
end;
procedure TFPanel1.Timer1Timer(Sender: TObject);
var i: integer;
begin
Panel:= TPanel.Create (FPanel1);
Panel.Color:= clYellow;
Panel.Caption:= '
F';
Panel.Width:= 49;
Panel.Height:= 33;
Panel.Left:= Random(ShSpiel.Width-60)+30;
Panel.Top:= Random(ShSpiel.Height-50)+30;
Panel.Parent:= FPanel1;
Panel.OnClick:= PanelWeg;
Zaehler:= Zaehler-1;
for i:=ComponentCount-1
downto 0
do begin
if Components[i]
is TPanel
then begin
if Panel.Visible= True
then begin
TPanel(Components[i]).Left:= Random(ShSpiel.Width-60)+30;
TPanel(Components[i]).Top:= Random(ShSpiel.Height-50)+30;
Punktefenster.MPktAnzeige.Lines.Add(IntToStr(Zaehler)+'
'+'
Punkte');
end
else begin
TPanel(Components[i]).Destroy;
end;
end;
end;
if Zaehler = 0
then begin
Timer1.Enabled:=False;
ShowMessage('
Verloren');
//break;
end
else
if Zaehler = 10
then begin
Timer1.Enabled:=False;
ShowMessage('
Gewonnen');
//break;
end;
end;
procedure TFPanel1.PanelWeg(Sender:TObject);
begin
TPanel(Sender).Hide;
Zaehler:= Zaehler+1;
Punktefenster.MPktAnzeige.Lines.Add(IntToStr(Zaehler)+'
'+'
Punkte');
end;
end.