
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    panel1: TPanel;
    Square1: TLabel;
    Square2: TLabel;
    Square3: TLabel;
    Square4: TLabel;
    Square5: TLabel;
    Square6: TLabel;
    Square9: TLabel;
    Square8: TLabel;
    Square7: TLabel;
    spinedit2: TSpinEdit;
    SpinEdit1: TSpinEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Button1: TButton;
    Button2: TButton;
    Image1: TImage;
    Image2: TImage;
    Image3: TImage;
    Image4: TImage;
    Image5: TImage;
    Image6: TImage;
    Image7: TImage;
    Image8: TImage;
    Image9: TImage;
    Image10: TImage;
    Image11: TImage;
    Button1X: TButton;
    Button4X: TButton;
    Button3X: TButton;
    Button5X: TButton;
    Button8X: TButton;
    Button7X: TButton;
    Button6X: TButton;
    Button9X: TButton;
    Button2X: TButton;
    Button1O: TButton;
    Button2O: TButton;
    Button3O: TButton;
    Button4O: TButton;
    Button5O: TButton;
    Button6O: TButton;
    Button7O: TButton;
    Button8O: TButton;
    Button9O: TButton;
    Xwint: TButton;
    Owint: TButton;
    NiemWint: TButton;
    Button3: TButton;
    MP3Player: TMediaPlayer;
    mp3list: TListBox;
    btnOpenFolder: TBitBtn;
    Txtfolder: TStaticText;
    Panel2: TPanel;
    Highscore: TMemo;
    Label6: TLabel;
    procedure Square1MouseLeave(Sender: TObject);
    procedure Square1MouseEnter(Sender: TObject);
    procedure Square2MouseEnter(Sender: TObject);
    procedure Square2MouseLeave(Sender: TObject);
    procedure Square3MouseEnter(Sender: TObject);
    procedure Square3MouseLeave(Sender: TObject);
    procedure Square4MouseEnter(Sender: TObject);
    procedure Square4MouseLeave(Sender: TObject);
    procedure Square5MouseEnter(Sender: TObject);
    procedure Square5MouseLeave(Sender: TObject);
    procedure Square6MouseEnter(Sender: TObject);
    procedure Square6MouseLeave(Sender: TObject);
    procedure Square7MouseEnter(Sender: TObject);
    procedure Square7MouseLeave(Sender: TObject);
    procedure Square8MouseEnter(Sender: TObject);
    procedure Square8MouseLeave(Sender: TObject);
    procedure Square9MouseEnter(Sender: TObject);
    procedure Square9MouseLeave(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Square1Click(Sender: TObject);
    procedure Square2Click(Sender: TObject);
    procedure Square3Click(Sender: TObject);
    procedure Square4Click(Sender: TObject);
    procedure Square5Click(Sender: TObject);
    procedure Square6Click(Sender: TObject);
    procedure Square7Click(Sender: TObject);
    procedure Square8Click(Sender: TObject);
    procedure Square9Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button1XClick(Sender: TObject);
    procedure Button1OClick(Sender: TObject);
    procedure Button2XClick(Sender: TObject);
    procedure Button2OClick(Sender: TObject);
    procedure Button3XClick(Sender: TObject);
    procedure Button3OClick(Sender: TObject);
    procedure Button4XClick(Sender: TObject);
    procedure Button4OClick(Sender: TObject);
    procedure Button5XClick(Sender: TObject);
    procedure Button5OClick(Sender: TObject);
    procedure Button6XClick(Sender: TObject);
    procedure Button6OClick(Sender: TObject);
    procedure Button7XClick(Sender: TObject);
    procedure Button7OClick(Sender: TObject);
    procedure Button8XClick(Sender: TObject);
    procedure Button8OClick(Sender: TObject);
    procedure Button9XClick(Sender: TObject);
    procedure Button9OClick(Sender: TObject);
    procedure XwintClick(Sender: TObject);
    procedure OwintClick(Sender: TObject);
    procedure NiemWintClick(Sender: TObject);
    procedure SpinEdit1Change(Sender: TObject);
    procedure spinedit2Change(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormClick(Sender: TObject);
    procedure btnOpenFolderClick(Sender: TObject);
    procedure mp3listClick(Sender: TObject);
    procedure FormActivate(Sender: TObject);



  private
    { Private declarations }
  public
    { Public declarations }

  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
Type
Tmijnarray=array [1..10] of string;

Var
z1,z2,z3,z4,z5,z6,z7,z8,z9:string;
keer1,keer2:string;
Highscores:Tmijnarray;
grootte:integer;


procedure Z_op_nul_zetten(var Z1,Z2,Z3,Z4,Z5,Z6,Z7,Z8,Z9:string);
begin
Z1:='0';
Z2:='0';
Z3:='0';
Z4:='0';
Z5:='0';
Z6:='0';
Z7:='0';
Z8:='0';
Z9:='0';
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Keer1:='1';
Keer2:='0';
z_op_nul_zetten(z1,z2,z3,z4,z5,z6,z7,z8,z9);

end;

procedure TForm1.Square1MouseEnter(Sender: TObject);
begin
square1.Color:=clskyblue;
end;

procedure TForm1.Square1MouseLeave(Sender: TObject);
begin
square1.Color:=clgray;
end;


procedure TForm1.Square2MouseEnter(Sender: TObject);
begin
square2.Color:=clfuchsia;
end;

procedure TForm1.Square2MouseLeave(Sender: TObject);
begin
square2.Color:=clgray;
end;

procedure TForm1.Square3MouseEnter(Sender: TObject);
begin
square3.Color:=clskyblue;
end;

procedure TForm1.Square3MouseLeave(Sender: TObject);
begin
square3.Color:=clgray;
end;

procedure TForm1.Square4MouseEnter(Sender: TObject);
begin
square4.Color:=clfuchsia;
end;

procedure TForm1.Square4MouseLeave(Sender: TObject);
begin
square4.Color:=clgray;
end;

procedure TForm1.Square5MouseEnter(Sender: TObject);
begin
square5.Color:=clskyblue;
end;

procedure TForm1.Square5MouseLeave(Sender: TObject);
begin
square5.Color:=clgray;
end;

procedure TForm1.Square6MouseEnter(Sender: TObject);
begin
square6.Color:=clfuchsia;
end;

procedure TForm1.Square6MouseLeave(Sender: TObject);
begin
square6.Color:=clgray;
end;

procedure TForm1.Square7MouseEnter(Sender: TObject);
begin
square7.Color:=clskyblue;
end;

procedure TForm1.Square7MouseLeave(Sender: TObject);
begin
square7.Color:=clgray;
end;

procedure TForm1.Square8MouseEnter(Sender: TObject);
begin
square8.Color:=clfuchsia;
end;

procedure TForm1.Square8MouseLeave(Sender: TObject);
begin
square8.Color:=clgray;
end;

procedure TForm1.Square9MouseEnter(Sender: TObject);
begin
square9.Color:=clskyblue;
end;

procedure TForm1.Square9MouseLeave(Sender: TObject);
begin
square9.Color:=clgray;
end;

procedure TForm1.Button2Click(Sender: TObject);
var Naamwin: string;
var Outfile: textfile;
var i,scorewin:integer;
var temp:Tmijnarray;
begin
If spinedit1.value>=spinedit2.Value then
scorewin:=spinedit1.Value
else
scorewin:=spinedit2.value;

Naamwin:=inputbox('Score opslaan', 'Vul je naam hier in!','');
If naamwin='' then
application.Terminate
else begin
for i:=1 to 10 do
  begin
  temp[i]:=Highscores[i];
  end;
for i:=1 to 9 do
  begin
  highscores[i+1]:=temp[i];
  end;
Highscores[1]:=Naamwin+' '+inttostr(scorewin);
Assignfile(Outfile,'Highscores.txt');
rewrite(Outfile);


for i:=1 to 10 do
  begin

  Writeln(Outfile,Highscores[i]);
  end;
closefile(Outfile);
application.terminate;
end;
end;

procedure TForm1.Square1Click(Sender: TObject);
begin
if Z1='0' then if keer1='1' then z1:='1';
if z1='1' then Button1XClick(self);
If z1='0' then if keer2='1' then z1:='2';
if z1='2' then Button1OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);


end;

procedure TForm1.Square2Click(Sender: TObject);
begin
if Z2='0' then if keer1='1' then z2:='1';
If z2='1' then Button2XClick(self);
If z2='0' then if keer2='1' then z2:='2';
If z2='2' then Button2OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
end;

procedure TForm1.Square3Click(Sender: TObject);
begin
if Z3='0' then if keer1='1' then z3:='1';
if z3='1' then Button3XClick(self);
If z3='0' then if keer2='1' then z3:='2';
if z3='2' then Button3OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
end;


procedure TForm1.Square4Click(Sender: TObject);
begin

if Z4='0' then if keer1='1' then z4:='1';
if z4='1' then Button4XClick(self);
If z4='0' then if keer2='1' then z4:='2';
if z4='2' then Button4OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
end;

procedure TForm1.Square5Click(Sender: TObject);
begin

if Z5='0' then if keer1='1' then z5:='1';
if z5='1' then Button5XClick(self);
If z5='0' then if keer2='1' then z5:='2';
if z5='2' then Button5OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
end;

procedure TForm1.Square6Click(Sender: TObject);
begin

if Z6='0' then if keer1='1' then z6:='1';
if z6='1' then Button6XClick(self);
If z6='0' then if keer2='1' then z6:='2';
if z6='2' then Button6OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
end;

procedure TForm1.Square7Click(Sender: TObject);
begin

if Z7='0' then if keer1='1' then z7:='1';
if z7='1' then Button7XClick(self);
If z7='0' then if keer2='1' then z7:='2';
if z7='2' then Button7OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
end;

procedure TForm1.Square8Click(Sender: TObject);
begin

if Z8='0' then if keer1='1' then z8:='1';
if z8='1' then Button8XClick(self);
If z8='0' then if keer2='1' then z8:='2';
if z8='2' then Button8OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
end;

procedure TForm1.Square9Click(Sender: TObject);
begin

if Z9='0' then if keer1='1' then z9:='1';
if z9='1' then Button9XClick(self);
If z9='0' then if keer2='1' then z9:='2';
if z9='2' then Button9OClick(self);

if (z1='x.jpg') and (z2= 'x.jpg') and (z3= 'x.jpg') then XWintClick(self);
if (z4='x.jpg') and (z5= 'x.jpg') and (z6= 'x.jpg') then XWintClick(self);
if (z7='x.jpg') and (z8= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z4= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);
if (z2='x.jpg') and (z5= 'x.jpg') and (z8= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z6= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z1='x.jpg') and (z5= 'x.jpg') and (z9= 'x.jpg') then XWintClick(self);
if (z3='x.jpg') and (z5= 'x.jpg') and (z7= 'x.jpg') then XWintClick(self);

if (z1='o.jpg') and (z2= 'o.jpg') and (z3= 'o.jpg') then OWintClick(self);
if (z4='o.jpg') and (z5= 'o.jpg') and (z6= 'o.jpg') then OWintClick(self);
if (z7='o.jpg') and (z8= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z4= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
if (z2='o.jpg') and (z5= 'o.jpg') and (z8= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z6= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z1='o.jpg') and (z5= 'o.jpg') and (z9= 'o.jpg') then OWintClick(self);
if (z3='o.jpg') and (z5= 'o.jpg') and (z7= 'o.jpg') then OWintClick(self);
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
keer1:='1';
keer2:='0';
z_op_nul_zetten(z1,z2,z3,z4,z5,z6,z7,z8,z9);
square1.transparent:=false;
square2.transparent:=false;
square3.transparent:=false;
square4.transparent:=false;
square5.transparent:=false;
square6.transparent:=false;
square7.transparent:=false;
square8.transparent:=false;
square9.transparent:=false;
image1.Visible:=true;
image2.Visible:=true;
image3.Visible:=true;
image4.Visible:=true;
image5.Visible:=true;
image6.Visible:=true;
image7.Visible:=true;
image8.Visible:=true;
image9.Visible:=true;
image10.Visible:=true;
image11.Visible:=true;

end;

procedure TForm1.Button1XClick(Sender: TObject);
begin
image3.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z1:='x.jpg';
image2.visible:=false;
image1.visible:=true;
square1.transparent:=true;
end;


procedure TForm1.Button1OClick(Sender: TObject);
begin
image3.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z1:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square1.transparent:=true;
end;

procedure TForm1.Button2XClick(Sender: TObject);
begin
image4.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z2:='x.jpg';
image2.visible:=false;
image1.visible:=true;
square2.transparent:=true;
end;

procedure TForm1.Button2OClick(Sender: TObject);
begin
image4.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z2:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square2.transparent:=true;
end;

procedure TForm1.Button3XClick(Sender: TObject);
begin
image9.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z3:='x.jpg';
image2.visible:=false;
image1.visible:=true;
square3.transparent:=true;
end;

procedure TForm1.Button3OClick(Sender: TObject);
begin
image9.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z3:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square3.transparent:=true;
end;

procedure TForm1.Button4XClick(Sender: TObject);
begin
image8.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z4:='x.jpg';
image2.visible:=false;
image1.visible:=true;
square4.transparent:=true;
end;

procedure TForm1.Button4OClick(Sender: TObject);
begin
image8.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z4:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square4.transparent:=true;
end;

procedure TForm1.Button5XClick(Sender: TObject);
begin
image6.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z5:='x.jpg';
image2.visible:=false;
image1.visible:=true;
square5.transparent:=true;
end;

procedure TForm1.Button5OClick(Sender: TObject);
begin
image6.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z5:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square5.transparent:=true;
end;

procedure TForm1.Button6XClick(Sender: TObject);
begin
image10.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z6:='x.jpg';
image2.visible:=false;
image1.visible:=true;
square6.transparent:=true;
end;

procedure TForm1.Button6OClick(Sender: TObject);
begin
image10.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z6:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square6.transparent:=true;
end;

procedure TForm1.Button7XClick(Sender: TObject);
begin
image7.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z7:='x.jpg';
image2.visible:=false;
image1.visible:=false;
square7.transparent:=true;
end;

procedure TForm1.Button7OClick(Sender: TObject);
begin
image7.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z7:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square7.transparent:=true;
end;

procedure TForm1.Button8XClick(Sender: TObject);
begin
image5.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z8:='x.jpg';
image2.visible:=false;
image1.visible:=true;
square8.transparent:=true;
end;

procedure TForm1.Button8OClick(Sender: TObject);
begin
image5.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z8:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square8.transparent:=true;
end;

procedure TForm1.Button9XClick(Sender: TObject);
begin
image11.picture.LoadFromFile('x.jpg');
Keer1:='0';
Keer2:='1';
z9:='x.jpg';
image2.visible:=false;
image1.visible:=true;
square9.transparent:=true;
end;

procedure TForm1.Button9OClick(Sender: TObject);
begin
image11.picture.LoadFromFile('o.jpg');
Keer1:='1';
Keer2:='0';
z9:='o.jpg';
image2.visible:=true;
image1.visible:=false;
square9.transparent:=true;
end;

procedure TForm1.XwintClick(Sender: TObject);
begin
spinedit1.value := Spinedit1.value +1;
ShowMessage('Het spelletje is afgelopen, Mickey Wint.');
Button1Click(self);
end;

procedure TForm1.OwintClick(Sender: TObject);
begin
spinedit2.value := Spinedit2.value +1;
ShowMessage('Het spelletje is afgelopen, Donald Wint.');
Button1Click(self);
end;

procedure TForm1.NiemWintClick(Sender: TObject);
begin
ShowMessage('Het spelletje is afgelopen, niemand heeft gewonnen.');
keer1:='1';
keer2:='0';
z_op_nul_zetten(z1,z2,z3,z4,z5,z6,z7,z8,z9);
square1.transparent:=false;
square2.transparent:=false;
square3.transparent:=false;
square4.transparent:=false;
square5.transparent:=false;
square6.transparent:=false;
square7.transparent:=false;
square8.transparent:=false;
square9.transparent:=false;
image3.Visible:=true;
image4.Visible:=true;
image5.Visible:=true;
image6.Visible:=true;
image7.Visible:=true;
image8.Visible:=true;
image9.Visible:=true;
image10.Visible:=true;
image11.Visible:=true;
end;

procedure TForm1.SpinEdit1Change(Sender: TObject);
begin
label4.Caption:=spinedit1.Text;
end;

procedure TForm1.spinedit2Change(Sender: TObject);
begin
label5.caption:=spinedit2.Text;
end;


procedure TForm1.Button3Click(Sender: TObject);
var Naamwin: string;
var Outfile: textfile;
var i,scorewin:integer;
var temp:Tmijnarray;
var infile:textfile;

begin
If spinedit1.value>=spinedit2.Value then
scorewin:=spinedit1.Value
else
scorewin:=spinedit2.value;

Naamwin:=inputbox('Score opslaan', 'Vul je naam hier in!','');
If naamwin='' then
application.Terminate
else begin
for i:=1 to 10 do
  begin
  temp[i]:=Highscores[i];
  end;
for i:=1 to 9 do
  begin
  highscores[i+1]:=temp[i];
  end;
Highscores[1]:=Naamwin+' '+inttostr(scorewin);
Assignfile(Outfile,'Highscores.txt');
rewrite(Outfile);


for i:=1 to 10 do
  begin

  Writeln(Outfile,Highscores[i]);
  end;
closefile(Outfile);

begin
grootte:=1;
assignfile(infile,'highscores.txt');
reset (infile);
for I:=1 to 10 do
begin

  readln(infile,highscores[i]);
  highscore.lines.add(highscores[i]);
  end;
closefile(infile);

keer1:='1';
keer2:='0';
z_op_nul_zetten(z1,z2,z3,z4,z5,z6,z7,z8,z9);
square1.transparent:=false;
square2.transparent:=false;
square3.transparent:=false;
square4.transparent:=false;
square5.transparent:=false;
square6.transparent:=false;
square7.transparent:=false;
square8.transparent:=false;
square9.transparent:=false;
image1.Visible:=true;
image2.Visible:=true;
image3.Visible:=true;
image4.Visible:=true;
image5.Visible:=true;
image6.Visible:=true;
image7.Visible:=true;
image8.Visible:=true;
image9.Visible:=true;
image10.Visible:=true;
image11.Visible:=true;
spinedit1.Value:=0;
spinedit2.Value:=0;
end;
end;
end;

procedure TForm1.FormClick(Sender: TObject);
begin
messagebeep(mb_ok);
end;



procedure FillMP3FileList(Folder: string; sl: TStrings);
var Rec : TSearchRec;
begin
 sl.Clear;
 if SysUtils.FindFirst(Folder + '*.mp3', faAnyFile, Rec) = 0 then
  try
    repeat
      sl.Add(Rec.Name);
    until SysUtils.FindNext(Rec) <> 0;
  finally
    SysUtils.FindClose(Rec);
  end;
end;






procedure TForm1.btnOpenFolderClick(Sender: TObject);

var mp3Folder : string;
begin
mp3Folder :=('C:\Documents and Settings\anne douven\Mijn documenten\Universiteit\Jaar 2\2.3\mijn eigen programma\de mijne\');
 if mp3Folder = '' then Exit;

 txtFolder.Caption := mp3Folder;
 FillMP3FileList(mp3Folder, mp3List.Items);
end;

procedure TForm1.mp3listClick(Sender: TObject);
var mp3File: string;
begin
  if mp3List.Items.Count=0 then exit;
  mp3File := Concat(txtFolder.Caption, mp3List.Items.Strings[mp3List.ItemIndex]);
  if not FileExists(mp3File) then begin
   ShowMessage('MP3 file '+#13#10+ mp3File +#13#10+'does not exist!');
   exit;
  end;
  mp3player.Close;
  mp3player.FileName:=mp3File;
  mp3player.Open;

end;



procedure TForm1.FormActivate(Sender: TObject);
var infile:textfile;
var i:integer;
begin
grootte:=1;
assignfile(infile,'highscores.txt');
reset (infile);
for I:=1 to 10 do
begin

  readln(infile,highscores[i]);
  highscore.lines.add(highscores[i]);
  end;
closefile(infile);
end;


end.
