unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, jpeg;
type
TForm1 =
class(TForm)
Image1: TImage;
Image2: TImage;
Image3: TImage;
Image4: TImage;
Image5: TImage;
Image6: TImage;
procedure FormCreate(Sender: TObject);
procedure Image1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
zweitekarte: boolean = true;
karte1, karte2: integer;
karte:
array [1..3]
of string;
position:
array [1..6]
of integer;
deckblatt1, deckblatt2:
string;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var anzahl, k, zufall, nummer: integer;
karte:
array [1..6]
of string;
begin
randomize;
while anzahl > 0
do
begin
zufall := random(anzahl)+1;
nummer[anzahl] := position[zufall];
for k := zufall
to anzahl-1
do
begin
position[k] := position[k+1];
end;
anzahl := anzahl -1;
end;
image1.Picture.LoadFromFile('
images/hansawappen.jpg');
image2.Picture.LoadFromFile('
images/hansawappen.jpg');
image3.Picture.LoadFromFile('
images/hansawappen.jpg');
image4.Picture.LoadFromFile('
images/hansawappen.jpg');
image5.Picture.LoadFromFile('
images/hansawappen.jpg');
image6.Picture.LoadFromFile('
images/hansawappen.jpg');
karte[1]:= '
images/spieler1.jpg';
karte[2]:= '
images/spieler2.jpg';
karte[3]:= '
images/spieler3.jpg';
position[1]:= 1; position[2]:= 2; position[3]:= 3;
position[4]:= 3; position[5]:= 2; position[6]:= 1;
end;
procedure TForm1.image1Click(Sender: TObject);
var i, k: integer;
begin
zweitekarte:=
not(zweitekarte);
i:= strtoint(timage(sender).
name[6]); showmessage('
position_'+inttostr(i)+'
gedrückt');
timage(sender).Picture.LoadFromFile(karte[position[i]]);
deckblatt1:= timage(sender).
name; showmessage('
deckblatt1'+'
wurde ausgewählt');
if zweitekarte
then begin
karte1:= i;
deckblatt1:= timage(sender).
Name;
end
else begin
karte2:= i;
deckblatt2:= timage(sender).
name;
end;
if zweitekarte
then
if position[karte1] <> position[karte2]
then
begin
messagedlgpos('
gesehn?', mtconfirmation, mbyesnocancel, 0, 400, 400);
for k:=0
to componentcount-1
do
if (timage(components[k]).name=deckblatt1)
or (timage(components[k]).name=deckblatt2)
then timage(components[k]).Picture.LoadFromFile('
hansawappen.jpg');
end
// else
end;
end.