unit game_test;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, jpeg, GIFImage, MPlayer;

type
  Tgame = class(TForm)
    field_0x0: TPanel;
    field_0x1: TPanel;
    field_0x2: TPanel;
    field_0x3: TPanel;
    field_0x4: TPanel;
    field_1x0: TPanel;
    field_1x1: TPanel;
    field_1x2: TPanel;
    field_1x3: TPanel;
    field_1x4: TPanel;
    field_2x0: TPanel;
    field_2x1: TPanel;
    field_2x2: TPanel;
    field_2x3: TPanel;
    field_2x4: TPanel;
    field_3x0: TPanel;
    field_3x1: TPanel;
    field_3x2: TPanel;
    field_3x3: TPanel;
    field_3x4: TPanel;
    field_4x0: TPanel;
    field_4x1: TPanel;
    field_4x2: TPanel;
    field_4x3: TPanel;
    field_4x4: TPanel;
    startgame: TButton;
    Button1: TButton;
    board: TImage;
    pic0x0: TImage;
    pic0x1: TImage;
    pic0x2: TImage;
    pic0x3: TImage;
    pic0x4: TImage;
    pic1x0: TImage;
    pic1x1: TImage;
    pic1x2: TImage;
    pic1x3: TImage;
    pic1x4: TImage;
    pic2x0: TImage;
    pic2x1: TImage;
    pic2x2: TImage;
    pic2x3: TImage;
    pic2x4: TImage;
    pic3x0: TImage;
    pic3x1: TImage;
    pic3x2: TImage;
    pic3x3: TImage;
    pic3x4: TImage;
    pic4x0: TImage;
    pic4x1: TImage;
    pic4x2: TImage;
    pic4x3: TImage;
    pic4x4: TImage;
    sound: TMediaPlayer;
    Button2: TButton;
    procedure startgameClick(Sender: TObject);
    procedure field_1x1Click(Sender: TObject);
    procedure field_0x0Click(Sender: TObject);
    procedure field_1x3Click(Sender: TObject);
    procedure field_3x1Click(Sender: TObject);
    procedure field_3x3Click(Sender: TObject);
    procedure field_0x1Click(Sender: TObject);
    procedure field_0x2Click(Sender: TObject);
    procedure field_0x3Click(Sender: TObject);
    procedure field_0x4Click(Sender: TObject);
    procedure field_1x0Click(Sender: TObject);
    procedure field_1x2Click(Sender: TObject);
    procedure field_1x4Click(Sender: TObject);
    procedure field_2x0Click(Sender: TObject);
    procedure field_2x1Click(Sender: TObject);
    procedure field_2x2Click(Sender: TObject);
    procedure field_2x3Click(Sender: TObject);
    procedure field_2x4Click(Sender: TObject);
    procedure field_3x0Click(Sender: TObject);
    procedure field_3x2Click(Sender: TObject);
    procedure field_3x4Click(Sender: TObject);
    procedure field_4x0Click(Sender: TObject);
    procedure field_4x1Click(Sender: TObject);
    procedure field_4x2Click(Sender: TObject);
    procedure field_4x3Click(Sender: TObject);
    procedure field_4x4Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    procedure fieldshow;
    procedure fieldshow2;
    procedure checkend;
    { Public declarations }
  end;

var
  game: Tgame;

var Matrix : Array[0..4] of Array[0..4] of Boolean;


implementation

{$R *.dfm}

procedure Tgame.startgameClick(Sender: TObject);
begin
 Matrix[0,0]:=false;
 Matrix[0,1]:=false;
 Matrix[0,2]:=false;
 Matrix[0,3]:=false;
 Matrix[0,4]:=false;

 Matrix[1,0]:=false;
 Matrix[1,1]:=true;
 Matrix[1,2]:=false;
 Matrix[1,3]:=true;
 Matrix[1,4]:=false;

 Matrix[2,0]:=false;
 Matrix[2,1]:=false;
 Matrix[2,2]:=false;
 Matrix[2,3]:=false;
 Matrix[2,4]:=false;

 Matrix[3,0]:=false;
 Matrix[3,1]:=true;
 Matrix[3,2]:=false;
 Matrix[3,3]:=true;
 Matrix[3,4]:=false;

 Matrix[4,0]:=false;
 Matrix[4,1]:=false;
 Matrix[4,2]:=false;
 Matrix[4,3]:=false;
 Matrix[4,4]:=false;

 fieldshow;
 fieldshow2;
end;

procedure Tgame.field_1x1Click(Sender: TObject);
begin
 if Matrix[1,1]=true then
  begin
    matrix[1,0]:= not matrix[1,0];
    matrix[1,1]:= not matrix[1,1];
    matrix[1,2]:= not matrix[1,2];
    matrix[1,3]:= not matrix[1,3];
    matrix[1,4]:= not matrix[1,4];

    matrix[0,1]:= not matrix[0,1];
    matrix[2,1]:= not matrix[2,1];
    matrix[3,1]:= not matrix[3,1];
    matrix[4,1]:= not matrix[4,1];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_0x0Click(Sender: TObject);
begin
 if Matrix[0,0]=true then
  begin
    matrix[0,0]:= not matrix[0,0];
    matrix[0,1]:= not matrix[0,1];
    matrix[0,2]:= not matrix[0,2];
    matrix[0,3]:= not matrix[0,3];
    matrix[0,4]:= not matrix[0,4];

    matrix[1,0]:= not matrix[1,0];
    matrix[2,0]:= not matrix[2,0];
    matrix[3,0]:= not matrix[3,0];
    matrix[4,0]:= not matrix[4,0];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_1x3Click(Sender: TObject);
begin
 if Matrix[1,3]=true then
  begin
    matrix[1,0]:= not matrix[1,0];
    matrix[1,1]:= not matrix[1,1];
    matrix[1,2]:= not matrix[1,2];
    matrix[1,3]:= not matrix[1,3];
    matrix[1,4]:= not matrix[1,4];

    matrix[0,3]:= not matrix[0,3];
    matrix[2,3]:= not matrix[2,3];
    matrix[3,3]:= not matrix[3,3];
    matrix[4,3]:= not matrix[4,3];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_3x1Click(Sender: TObject);
begin
 if Matrix[3,1]=true then
  begin
    matrix[3,0]:= not matrix[3,0];
    matrix[3,1]:= not matrix[3,1];
    matrix[3,2]:= not matrix[3,2];
    matrix[3,3]:= not matrix[3,3];
    matrix[3,4]:= not matrix[3,4];

    matrix[0,1]:= not matrix[0,1];
    matrix[1,1]:= not matrix[1,1];
    matrix[2,1]:= not matrix[2,1];
    matrix[4,1]:= not matrix[4,1];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_3x3Click(Sender: TObject);
begin
 if Matrix[3,3]=true then
  begin
    matrix[3,0]:= not matrix[3,0];
    matrix[3,1]:= not matrix[3,1];
    matrix[3,2]:= not matrix[3,2];
    matrix[3,3]:= not matrix[3,3];
    matrix[3,4]:= not matrix[3,4];

    matrix[0,3]:= not matrix[0,3];
    matrix[1,3]:= not matrix[1,3];
    matrix[2,3]:= not matrix[2,3];
    matrix[4,3]:= not matrix[4,3];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_0x1Click(Sender: TObject);
begin
 if Matrix[0,1]=true then
  begin
    matrix[0,0]:= not matrix[0,0];
    matrix[0,1]:= not matrix[0,1];
    matrix[0,2]:= not matrix[0,2];
    matrix[0,3]:= not matrix[0,3];
    matrix[0,4]:= not matrix[0,4];

    matrix[1,1]:= not matrix[1,1];
    matrix[2,1]:= not matrix[2,1];
    matrix[3,1]:= not matrix[3,1];
    matrix[4,1]:= not matrix[4,1];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_0x2Click(Sender: TObject);
begin
 if Matrix[0,2]=true then
  begin
    matrix[0,0]:= not matrix[0,0];
    matrix[0,1]:= not matrix[0,1];
    matrix[0,2]:= not matrix[0,2];
    matrix[0,3]:= not matrix[0,3];
    matrix[0,4]:= not matrix[0,4];

    matrix[1,2]:= not matrix[1,2];
    matrix[2,2]:= not matrix[2,2];
    matrix[3,2]:= not matrix[3,2];
    matrix[4,2]:= not matrix[4,2];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_0x3Click(Sender: TObject);
begin
 if Matrix[0,3]=true then
  begin
    matrix[0,0]:= not matrix[0,0];
    matrix[0,1]:= not matrix[0,1];
    matrix[0,2]:= not matrix[0,2];
    matrix[0,3]:= not matrix[0,3];
    matrix[0,4]:= not matrix[0,4];

    matrix[1,3]:= not matrix[1,3];
    matrix[2,3]:= not matrix[2,3];
    matrix[3,3]:= not matrix[3,3];
    matrix[4,3]:= not matrix[4,3];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_0x4Click(Sender: TObject);
begin
 if Matrix[0,4]=true then
  begin
    matrix[0,0]:= not matrix[0,0];
    matrix[0,1]:= not matrix[0,1];
    matrix[0,2]:= not matrix[0,2];
    matrix[0,3]:= not matrix[0,3];
    matrix[0,4]:= not matrix[0,4];

    matrix[1,4]:= not matrix[1,4];
    matrix[2,4]:= not matrix[2,4];
    matrix[3,4]:= not matrix[3,4];
    matrix[4,4]:= not matrix[4,4];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_1x0Click(Sender: TObject);
begin
 if Matrix[1,0]=true then
  begin
    matrix[1,0]:= not matrix[1,0];
    matrix[1,1]:= not matrix[1,1];
    matrix[1,2]:= not matrix[1,2];
    matrix[1,3]:= not matrix[1,3];
    matrix[1,4]:= not matrix[1,4];

    matrix[0,0]:= not matrix[0,0];
    matrix[2,0]:= not matrix[2,0];
    matrix[3,0]:= not matrix[3,0];
    matrix[4,0]:= not matrix[4,0];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_1x2Click(Sender: TObject);
begin
 if Matrix[1,2]=true then
  begin
    matrix[1,0]:= not matrix[1,0];
    matrix[1,1]:= not matrix[1,1];
    matrix[1,2]:= not matrix[1,2];
    matrix[1,3]:= not matrix[1,3];
    matrix[1,4]:= not matrix[1,4];

    matrix[0,2]:= not matrix[0,2];
    matrix[2,2]:= not matrix[2,2];
    matrix[3,2]:= not matrix[3,2];
    matrix[4,2]:= not matrix[4,2];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_1x4Click(Sender: TObject);
begin
 if Matrix[1,4]=true then
  begin
    matrix[1,0]:= not matrix[1,0];
    matrix[1,1]:= not matrix[1,1];
    matrix[1,2]:= not matrix[1,2];
    matrix[1,3]:= not matrix[1,3];
    matrix[1,4]:= not matrix[1,4];

    matrix[0,4]:= not matrix[0,4];
    matrix[2,4]:= not matrix[2,4];
    matrix[3,4]:= not matrix[3,4];
    matrix[4,4]:= not matrix[4,4];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_2x0Click(Sender: TObject);
begin
 if Matrix[2,0]=true then
  begin
    matrix[2,0]:= not matrix[2,0];
    matrix[2,1]:= not matrix[2,1];
    matrix[2,2]:= not matrix[2,2];
    matrix[2,3]:= not matrix[2,3];
    matrix[2,4]:= not matrix[2,4];

    matrix[0,0]:= not matrix[0,0];
    matrix[1,0]:= not matrix[1,0];
    matrix[3,0]:= not matrix[3,0];
    matrix[4,0]:= not matrix[4,0];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_2x1Click(Sender: TObject);
begin
 if Matrix[2,1]=true then
  begin
    matrix[2,0]:= not matrix[2,0];
    matrix[2,1]:= not matrix[2,1];
    matrix[2,2]:= not matrix[2,2];
    matrix[2,3]:= not matrix[2,3];
    matrix[2,4]:= not matrix[2,4];

    matrix[0,1]:= not matrix[0,1];
    matrix[1,1]:= not matrix[1,1];
    matrix[3,1]:= not matrix[3,1];
    matrix[4,1]:= not matrix[4,1];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_2x2Click(Sender: TObject);
begin
 if Matrix[2,2]=true then
  begin
    matrix[2,0]:= not matrix[2,0];
    matrix[2,1]:= not matrix[2,1];
    matrix[2,2]:= not matrix[2,2];
    matrix[2,3]:= not matrix[2,3];
    matrix[2,4]:= not matrix[2,4];

    matrix[0,2]:= not matrix[0,2];
    matrix[1,2]:= not matrix[1,2];
    matrix[3,2]:= not matrix[3,2];
    matrix[4,2]:= not matrix[4,2];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_2x3Click(Sender: TObject);
begin
 if Matrix[2,3]=true then
  begin
    matrix[2,0]:= not matrix[2,0];
    matrix[2,1]:= not matrix[2,1];
    matrix[2,2]:= not matrix[2,2];
    matrix[2,3]:= not matrix[2,3];
    matrix[2,4]:= not matrix[2,4];

    matrix[0,3]:= not matrix[0,3];
    matrix[1,3]:= not matrix[1,3];
    matrix[3,3]:= not matrix[3,3];
    matrix[4,3]:= not matrix[4,3];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_2x4Click(Sender: TObject);
begin
 if Matrix[2,4]=true then
  begin
    matrix[2,0]:= not matrix[2,0];
    matrix[2,1]:= not matrix[2,1];
    matrix[2,2]:= not matrix[2,2];
    matrix[2,3]:= not matrix[2,3];
    matrix[2,4]:= not matrix[2,4];

    matrix[0,4]:= not matrix[0,4];
    matrix[1,4]:= not matrix[1,4];
    matrix[3,4]:= not matrix[3,4];
    matrix[4,4]:= not matrix[4,4];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_3x0Click(Sender: TObject);
begin
 if Matrix[3,0]=true then
  begin
    matrix[3,0]:= not matrix[3,0];
    matrix[3,1]:= not matrix[3,1];
    matrix[3,2]:= not matrix[3,2];
    matrix[3,3]:= not matrix[3,3];
    matrix[3,4]:= not matrix[3,4];

    matrix[0,0]:= not matrix[0,0];
    matrix[1,0]:= not matrix[1,0];
    matrix[2,0]:= not matrix[2,0];
    matrix[4,0]:= not matrix[4,0];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_3x2Click(Sender: TObject);
begin
 if Matrix[3,2]=true then
  begin
    matrix[3,0]:= not matrix[3,0];
    matrix[3,1]:= not matrix[3,1];
    matrix[3,2]:= not matrix[3,2];
    matrix[3,3]:= not matrix[3,3];
    matrix[3,4]:= not matrix[3,4];

    matrix[0,2]:= not matrix[0,2];
    matrix[1,2]:= not matrix[1,2];
    matrix[2,2]:= not matrix[2,2];
    matrix[4,2]:= not matrix[4,2];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_3x4Click(Sender: TObject);
begin
 if Matrix[3,4]=true then
  begin
    matrix[3,0]:= not matrix[3,0];
    matrix[3,1]:= not matrix[3,1];
    matrix[3,2]:= not matrix[3,2];
    matrix[3,3]:= not matrix[3,3];
    matrix[3,4]:= not matrix[3,4];

    matrix[0,4]:= not matrix[0,4];
    matrix[1,4]:= not matrix[1,4];
    matrix[2,4]:= not matrix[2,4];
    matrix[4,4]:= not matrix[4,4];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_4x0Click(Sender: TObject);
begin
 if Matrix[4,0]=true then
  begin
    matrix[4,0]:= not matrix[4,0];
    matrix[4,1]:= not matrix[4,1];
    matrix[4,2]:= not matrix[4,2];
    matrix[4,3]:= not matrix[4,3];
    matrix[4,4]:= not matrix[4,4];

    matrix[0,0]:= not matrix[0,0];
    matrix[1,0]:= not matrix[1,0];
    matrix[2,0]:= not matrix[2,0];
    matrix[3,0]:= not matrix[3,0];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_4x1Click(Sender: TObject);
begin
 if Matrix[4,1]=true then
  begin
    matrix[4,0]:= not matrix[4,0];
    matrix[4,1]:= not matrix[4,1];
    matrix[4,2]:= not matrix[4,2];
    matrix[4,3]:= not matrix[4,3];
    matrix[4,4]:= not matrix[4,4];

    matrix[0,1]:= not matrix[0,1];
    matrix[1,1]:= not matrix[1,1];
    matrix[2,1]:= not matrix[2,1];
    matrix[3,1]:= not matrix[3,1];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_4x2Click(Sender: TObject);
begin
 if Matrix[4,2]=true then
  begin
    matrix[4,0]:= not matrix[4,0];
    matrix[4,1]:= not matrix[4,1];
    matrix[4,2]:= not matrix[4,2];
    matrix[4,3]:= not matrix[4,3];
    matrix[4,4]:= not matrix[4,4];

    matrix[0,2]:= not matrix[0,2];
    matrix[1,2]:= not matrix[1,2];
    matrix[2,2]:= not matrix[2,2];
    matrix[3,2]:= not matrix[3,2];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_4x3Click(Sender: TObject);
begin
 if Matrix[4,3]=true then
  begin
    matrix[4,0]:= not matrix[4,0];
    matrix[4,1]:= not matrix[4,1];
    matrix[4,2]:= not matrix[4,2];
    matrix[4,3]:= not matrix[4,3];
    matrix[4,4]:= not matrix[4,4];

    matrix[0,3]:= not matrix[0,3];
    matrix[1,3]:= not matrix[1,3];
    matrix[2,3]:= not matrix[2,3];
    matrix[3,3]:= not matrix[3,3];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure Tgame.field_4x4Click(Sender: TObject);
begin
 if Matrix[4,4]=true then
  begin
    matrix[4,0]:= not matrix[4,0];
    matrix[4,1]:= not matrix[4,1];
    matrix[4,2]:= not matrix[4,2];
    matrix[4,3]:= not matrix[4,3];
    matrix[4,4]:= not matrix[4,4];

    matrix[0,4]:= not matrix[0,4];
    matrix[1,4]:= not matrix[1,4];
    matrix[2,4]:= not matrix[2,4];
    matrix[3,4]:= not matrix[3,4];

    fieldshow;
    fieldshow2;
    checkend;
  end
end;

procedure TGame.fieldshow;
begin
 if Matrix[0,0]=true then field_0x0.color:=clred else field_0x0.color:=clgreen;
 if Matrix[0,1]=true then field_0x1.color:=clred else field_0x1.color:=clgreen;
 if Matrix[0,2]=true then field_0x2.color:=clred else field_0x2.color:=clgreen;
 if Matrix[0,3]=true then field_0x3.color:=clred else field_0x3.color:=clgreen;
 if Matrix[0,4]=true then field_0x4.color:=clred else field_0x4.color:=clgreen;

 if Matrix[1,0]=true then field_1x0.color:=clred else field_1x0.color:=clgreen;
 if Matrix[1,1]=true then field_1x1.color:=clred else field_1x1.color:=clgreen;
 if Matrix[1,2]=true then field_1x2.color:=clred else field_1x2.color:=clgreen;
 if Matrix[1,3]=true then field_1x3.color:=clred else field_1x3.color:=clgreen;
 if Matrix[1,4]=true then field_1x4.color:=clred else field_1x4.color:=clgreen;

 if Matrix[2,0]=true then field_2x0.color:=clred else field_2x0.color:=clgreen;
 if Matrix[2,1]=true then field_2x1.color:=clred else field_2x1.color:=clgreen;
 if Matrix[2,2]=true then field_2x2.color:=clred else field_2x2.color:=clgreen;
 if Matrix[2,3]=true then field_2x3.color:=clred else field_2x3.color:=clgreen;
 if Matrix[2,4]=true then field_2x4.color:=clred else field_2x4.color:=clgreen;

 if Matrix[3,0]=true then field_3x0.color:=clred else field_3x0.color:=clgreen;
 if Matrix[3,1]=true then field_3x1.color:=clred else field_3x1.color:=clgreen;
 if Matrix[3,2]=true then field_3x2.color:=clred else field_3x2.color:=clgreen;
 if Matrix[3,3]=true then field_3x3.color:=clred else field_3x3.color:=clgreen;
 if Matrix[3,4]=true then field_3x4.color:=clred else field_3x4.color:=clgreen;

 if Matrix[4,0]=true then field_4x0.color:=clred else field_4x0.color:=clgreen;
 if Matrix[4,1]=true then field_4x1.color:=clred else field_4x1.color:=clgreen;
 if Matrix[4,2]=true then field_4x2.color:=clred else field_4x2.color:=clgreen;
 if Matrix[4,3]=true then field_4x3.color:=clred else field_4x3.color:=clgreen;
 if Matrix[4,4]=true then field_4x4.color:=clred else field_4x4.color:=clgreen;
end;

procedure TGame.fieldshow2;
begin
 if Matrix[0,0]=true then pic0x0.visible:=true else pic0x0.visible:=false;
 if Matrix[0,1]=true then pic0x1.visible:=true else pic0x1.visible:=false;
 if Matrix[0,2]=true then pic0x2.visible:=true else pic0x2.visible:=false;
 if Matrix[0,3]=true then pic0x3.visible:=true else pic0x3.visible:=false;
 if Matrix[0,4]=true then pic0x4.visible:=true else pic0x4.visible:=false;

 if Matrix[1,0]=true then pic1x0.visible:=true else pic1x0.visible:=false;
 if Matrix[1,1]=true then pic1x1.visible:=true else pic1x1.visible:=false;
 if Matrix[1,2]=true then pic1x2.visible:=true else pic1x2.visible:=false;
 if Matrix[1,3]=true then pic1x3.visible:=true else pic1x3.visible:=false;
 if Matrix[1,4]=true then pic1x4.visible:=true else pic1x4.visible:=false;

 if Matrix[2,0]=true then pic2x0.visible:=true else pic2x0.visible:=false;
 if Matrix[2,1]=true then pic2x1.visible:=true else pic2x1.visible:=false;
 if Matrix[2,2]=true then pic2x2.visible:=true else pic2x2.visible:=false;
 if Matrix[2,3]=true then pic2x3.visible:=true else pic2x3.visible:=false;
 if Matrix[2,4]=true then pic2x4.visible:=true else pic2x4.visible:=false;

 if Matrix[3,0]=true then pic3x0.visible:=true else pic3x0.visible:=false;
 if Matrix[3,1]=true then pic3x1.visible:=true else pic3x1.visible:=false;
 if Matrix[3,2]=true then pic3x2.visible:=true else pic3x2.visible:=false;
 if Matrix[3,3]=true then pic3x3.visible:=true else pic3x3.visible:=false;
 if Matrix[3,4]=true then pic3x4.visible:=true else pic3x4.visible:=false;

 if Matrix[4,0]=true then pic4x0.visible:=true else pic4x0.visible:=false;
 if Matrix[4,1]=true then pic4x1.visible:=true else pic4x1.visible:=false;
 if Matrix[4,2]=true then pic4x2.visible:=true else pic4x2.visible:=false;
 if Matrix[4,3]=true then pic4x3.visible:=true else pic4x3.visible:=false;
 if Matrix[4,4]=true then pic4x4.visible:=true else pic4x4.visible:=false;
end;

procedure TGame.checkend;
begin
 sound.FileName:='resources\game\game_sound.avi';
 sound.Open;
 sound.play;

 if  (Matrix[0,0]=false)
 and (Matrix[0,1]=false)
 and (Matrix[0,2]=false)
 and (Matrix[0,3]=false)
 and (Matrix[0,4]=false)
 and (Matrix[1,0]=false)
 and (Matrix[1,1]=false)
 and (Matrix[1,2]=false)
 and (Matrix[1,3]=false)
 and (Matrix[1,4]=false)
 and (Matrix[2,0]=false)
 and (Matrix[2,1]=false)
 and (Matrix[2,2]=false)
 and (Matrix[2,3]=false)
 and (Matrix[2,4]=false)
 and (Matrix[3,0]=false)
 and (Matrix[3,1]=false)
 and (Matrix[3,2]=false)
 and (Matrix[3,3]=false)
 and (Matrix[3,4]=false)
 and (Matrix[4,0]=false)
 and (Matrix[4,1]=false)
 and (Matrix[4,2]=false)
 and (Matrix[4,3]=false)
 and (Matrix[4,4]=false)

 then showmessagepos('You win!', 400, 400);
end;

procedure Tgame.Button1Click(Sender: TObject);
begin
 Matrix[0,0]:=true;
 Matrix[0,1]:=false;
 Matrix[0,2]:=false;
 Matrix[0,3]:=false;
 Matrix[0,4]:=true;

 Matrix[1,0]:=false;
 Matrix[1,1]:=true;
 Matrix[1,2]:=false;
 Matrix[1,3]:=true;
 Matrix[1,4]:=false;

 Matrix[2,0]:=false;
 Matrix[2,1]:=false;
 Matrix[2,2]:=false;
 Matrix[2,3]:=false;
 Matrix[2,4]:=false;

 Matrix[3,0]:=false;
 Matrix[3,1]:=true;
 Matrix[3,2]:=false;
 Matrix[3,3]:=true;
 Matrix[3,4]:=false;

 Matrix[4,0]:=true;
 Matrix[4,1]:=false;
 Matrix[4,2]:=false;
 Matrix[4,3]:=false;
 Matrix[4,4]:=true;

 fieldshow;
 fieldshow2;
end;

procedure Tgame.Button2Click(Sender: TObject);
begin
 Matrix[0,0]:=false;
 Matrix[0,1]:=false;
 Matrix[0,2]:=false;
 Matrix[0,3]:=false;
 Matrix[0,4]:=false;

 Matrix[1,0]:=false;
 Matrix[1,1]:=false;
 Matrix[1,2]:=true;
 Matrix[1,3]:=false;
 Matrix[1,4]:=false;

 Matrix[2,0]:=false;
 Matrix[2,1]:=true;
 Matrix[2,2]:=false;
 Matrix[2,3]:=true;
 Matrix[2,4]:=false;

 Matrix[3,0]:=false;
 Matrix[3,1]:=false;
 Matrix[3,2]:=true;
 Matrix[3,3]:=false;
 Matrix[3,4]:=false;

 Matrix[4,0]:=false;
 Matrix[4,1]:=false;
 Matrix[4,2]:=false;
 Matrix[4,3]:=false;
 Matrix[4,4]:=false;

 fieldshow;
 fieldshow2;
end;

end.
