unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, IDImage;
const
MaxMemoryArray=36;
type
TMemoryArray=Array[1..MaxMemoryArray]
of Integer;
TForm1 =
class(TForm)
StatusBar1: TStatusBar;
Panel2: TPanel;
IDImage2: TIDImage;
Panel3: TPanel;
IDImage3: TIDImage;
Panel4: TPanel;
IDImage4: TIDImage;
Panel5: TPanel;
IDImage5: TIDImage;
Panel6: TPanel;
IDImage6: TIDImage;
Panel7: TPanel;
IDImage7: TIDImage;
Panel8: TPanel;
IDImage8: TIDImage;
Panel9: TPanel;
IDImage9: TIDImage;
Panel10: TPanel;
IDImage10: TIDImage;
Panel11: TPanel;
IDImage11: TIDImage;
Panel12: TPanel;
IDImage12: TIDImage;
Panel13: TPanel;
IDImage13: TIDImage;
Panel14: TPanel;
IDImage14: TIDImage;
Panel15: TPanel;
IDImage15: TIDImage;
Panel16: TPanel;
IDImage16: TIDImage;
Panel17: TPanel;
IDImage17: TIDImage;
Panel18: TPanel;
IDImage18: TIDImage;
Panel19: TPanel;
IDImage19: TIDImage;
Panel20: TPanel;
IDImage20: TIDImage;
Panel21: TPanel;
IDImage21: TIDImage;
Panel22: TPanel;
IDImage22: TIDImage;
Panel23: TPanel;
IDImage23: TIDImage;
Panel24: TPanel;
IDImage24: TIDImage;
Panel25: TPanel;
IDImage25: TIDImage;
Panel26: TPanel;
IDImage26: TIDImage;
Panel27: TPanel;
IDImage27: TIDImage;
Panel28: TPanel;
IDImage28: TIDImage;
Panel29: TPanel;
IDImage29: TIDImage;
Panel30: TPanel;
IDImage30: TIDImage;
Panel31: TPanel;
IDImage31: TIDImage;
Panel32: TPanel;
IDImage32: TIDImage;
Panel33: TPanel;
IDImage33: TIDImage;
Panel34: TPanel;
IDImage34: TIDImage;
Panel35: TPanel;
IDImage35: TIDImage;
Panel36: TPanel;
IDImage36: TIDImage;
Panel1: TPanel;
IDImage1: TIDImage;
procedure MouseEnter(Sender: TObject);
procedure MouseLeave(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Mischen;
procedure OnImgClick(Sender: TObject);
private
{ Private-Deklarationen }
count,punkte,versuche: Integer;
Sender1: TObject;
FMemoryArray: TMemoryArray;
procedure FillArray;
procedure Scramble;
procedure SetIDImage;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.mischen;
begin
Randomize;
FillArray;
Scramble;
SetIDImage;
count:=0;
punkte:=0;
versuche:=0;
end;
procedure TForm1.FillArray;
var
iCnt,jCnt:Integer;
ok:Boolean;
begin
For iCnt:=Low(FMemoryArray)
to High(FMemoryArray)
div 2
do begin
Repeat
ok:=true;
FMemoryArray[iCnt]:=Random(100);
For jCnt:=Low(FMemoryArray)
to iCnt-1
do begin
if FMemoryArray[iCnt]=FMemoryArray[jCnt]
then begin
ok:=false;
Break;
end;
end;
Until ok;
FMemoryArray[iCnt+High(FMemoryArray)
div 2]:=FMemoryArray[iCnt];
end;
end;
procedure TForm1.Scramble;
var
iCnt,jCnt,Swap:Integer;
begin
For iCnt:=Low(FMemoryArray)
to High(FMemoryArray)
do begin
jCnt:=Random(High(FMemoryArray))+1;
Swap:=FMemoryArray[iCnt];
FMemoryArray[iCnt]:=FMemoryArray[jCnt];
FMemoryArray[jCnt]:=Swap;
end;
end;
procedure TForm1.SetIDImage;
var
iCnt:Integer;
IDImage:TIDImage;
begin
For iCnt:=Low(FMemoryArray)
to High(FMemoryArray)
do begin
IDImage:=TIDImage(FindComponent('
IDImage'+IntToStr(iCnt)));
IDImage.ID:=IntToStr(FMemoryArray[iCnt]);
end;
end;
procedure TForm1.MouseEnter(Sender: TObject);
begin
if Sender
is TIDImage
then
(Sender
as TIDImage).Picture.LoadFromFile('
/Icons/Hintergrund1.bmp');
end;
procedure TForm1.MouseLeave(Sender: TObject);
begin
if Sender
is TIDImage
then
(Sender
as TIDImage).Picture.LoadFromFile('
/Icons/Hintergrund2.bmp');
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
mischen;
end;
procedure TForm1.OnImgClick(Sender: TObject);
begin
If Sender
is TIDImage
then
count:=count+1;
if count=1
then begin
Sender1:=Sender;
(Sender1
as TIDImage).Picture.LoadFromFile('
/Icons/'+ID+'
.ico');
(Sender1
as TIDImage).Enabled:=false;
end;
if count=2
then begin
(Sender
as TIDImage).Enabled:=false;
count:=0;
versuche:=versuche+1;
sleep(1000);
if (Sender1
as TIDImage).ID=(Sender
as TIDImage).ID
then begin
(Sender
as TIDImage).hide;
(Sender1
as TIDImage).hide;
Punkte:=Punkte+1;
StatusBar1.Panels[0].Text:='
Punkte: '+IntToStr(punkte);
end else begin
(Sender1
as TIDImage).Enabled:=true;
(Sender
as TIDImage).Enabled:=true;
end;
StatusBar1.Panels[1].Text:='
Versuche: '+IntToStr(versuche);
end;
end;
end.