unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, jpeg, mmsystem, Menus;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
Button8: TButton;
Button9: TButton;
MainMenu1: TMainMenu;
F1: TMenuItem;
Red1: TMenuItem;
D1: TMenuItem;
Grn1: TMenuItem;
Yellow1: TMenuItem;
White1: TMenuItem;
Black1: TMenuItem;
Ende1: TMenuItem;
Neu1: TMenuItem;
Panel1: TPanel;
Panel2: TPanel;
Button10: TButton;
Button11: TButton;
Panel3: TPanel;
Panel4: TPanel;
Panel5: TPanel;
Panel6: TPanel;
LabelVS: TLabel;
Orange1: TMenuItem;
Grau1: TMenuItem;
Lila1: TMenuItem;
Pink1: TMenuItem;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
procedure F1Click(Sender: TObject);
procedure Red1Click(Sender: TObject);
procedure Grn1Click(Sender: TObject);
procedure Yellow1Click(Sender: TObject);
procedure White1Click(Sender: TObject);
procedure Black1Click(Sender: TObject);
procedure Ende1Click(Sender: TObject);
procedure Neu1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure Button8Click(Sender: TObject);
procedure Button9Click(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure Button11Click(Sender: TObject);
procedure Button10Click(Sender: TObject);
procedure Orange1Click(Sender: TObject);
procedure Grau1Click(Sender: TObject);
procedure Lila1Click(Sender: TObject);
procedure Pink1Click(Sender: TObject);
procedure Maroon1Click(Sender: TObject);
procedure Olive1Click(Sender: TObject);
procedure Trkise1Click(Sender: TObject);
private
procedure Gewinner;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
Button1:
String;
Button2:
String;
Button3:
String;
Button4:
String;
Button5:
String;
Button6:
String;
Button7:
String;
Button8:
String;
Button9:
String;
Gewinner:Boolean;
Spieler:Integer;
Spieler1:
string;
Spieler2:
string;
CoX: boolean;
player:
string;
punkte1:integer;
punkte2:integer;
implementation
{$R *.DFM}
procedure TForm1.F1Click(Sender: TObject);
begin
Form1.Color:=clblue;
end;
procedure TForm1.Red1Click(Sender: TObject);
begin
Form1.Color:=clred;
end;
procedure TForm1.Grn1Click(Sender: TObject);
begin
Form1.Color:=clgreen;
end;
procedure TForm1.Yellow1Click(Sender: TObject);
begin
Form1.Color:=clyellow;
end;
procedure TForm1.White1Click(Sender: TObject);
begin
Form1.Color:=clwhite;
end;
procedure TForm1.Black1Click(Sender: TObject);
begin
Form1.Color:=clblack;
end;
procedure TForm1.Ende1Click(Sender: TObject);
begin
Form1.close;
end;
procedure TForm1.Neu1Click(Sender: TObject);
begin
Button1.Caption:='
';
Button2.Caption:='
';
Button3.Caption:='
';
Button4.Caption:='
';
Button5.Caption:='
';
Button6.Caption:='
';
Button7.Caption:='
';
Button8.Caption:='
';
Button9.Caption:='
';
Panel2.Caption:='
Klicken sie auf ein Spielfeld, um zu starten.';
Panel2.Color:=clyellow;
Button1.enabled:=true;
Button2.enabled:=true;
Button3.enabled:=true;
Button4.enabled:=true;
Button5.enabled:=true;
Button6.enabled:=true;
Button7.enabled:=true;
Button8.enabled:=true;
Button9.enabled:=true;
Button10.Visible:=false;
Button11.Visible:=false;
Button1.Visible:=true;
Button2.Visible:=true;
Button3.Visible:=true;
Button4.Visible:=true;
Button5.Visible:=true;
Button6.Visible:=true;
Button7.Visible:=true;
Button8.Visible:=true;
Button9.Visible:=true;
Panel3.Visible:=true;
Panel4.Visible:=true;
Panel5.Visible:=true;
Panel6.Visible:=true;
end;
procedure TForm1.Gewinner;
begin
if (Button1.caption='
O')
and (Button2.caption='
O')
and (Button3.caption='
O')
or (Button4.caption='
O')
and (Button5.caption='
O')
and (Button6.caption='
O')
or (Button7.caption='
O')
and (Button8.caption='
O')
and (Button9.caption='
O')
or (Button1.caption='
O')
and (Button4.caption='
O')
and (Button7.caption='
O')
or (Button2.caption='
O')
and (Button5.caption='
O')
and (Button8.caption='
O')
or (Button3.caption='
O')
and (Button6.caption='
O')
and (Button9.caption='
O')
or (Button1.caption='
O')
and (Button5.caption='
O')
and (Button9.caption='
O')
or (Button3.caption='
O')
and (Button5.caption='
O')
and (Button7.caption='
O')
then
begin
Panel2.Caption:=Spieler1 + '
hat gewonnen';
sndPlaySound('
ablaus.wav', SND_ASYNC);
Button10.Visible:=true;
Button11.Visible:=true;
Punkte1:=Punkte1 + 1;
Button1.Visible:=false;
Button2.Visible:=false;
Button3.Visible:=false;
Button4.Visible:=false;
Button5.Visible:=false;
Button6.Visible:=false;
Button7.Visible:=false;
Button8.Visible:=false;
Button9.Visible:=false;
Panel3.Visible:=false;
Panel4.Visible:=false;
Panel5.Visible:=false;
Panel6.Visible:=false;
end;
if (Button1.caption='
X')
and (Button2.caption='
X')
and (Button3.caption='
X')
or (Button4.caption='
X')
and (Button5.caption='
X')
and (Button6.caption='
X')
or (Button7.caption='
X')
and (Button8.caption='
X')
and (Button9.caption='
X')
or (Button1.caption='
X')
and (Button4.caption='
X')
and (Button7.caption='
X')
or (Button2.caption='
X')
and (Button5.caption='
X')
and (Button8.caption='
X')
or (Button3.caption='
X')
and (Button6.caption='
X')
and (Button9.caption='
X')
or (Button1.caption='
X')
and (Button5.caption='
X')
and (Button9.caption='
X')
or (Button3.caption='
X')
and (Button5.caption='
X')
and (Button7.caption='
X')
then
begin
Panel2.Caption:=Spieler2 + '
hat gewonnen';
sndPlaySound('
ablaus.wav', SND_ASYNC);
Button10.Visible:=true;
Button11.Visible:=true;
Punkte2:=Punkte2 + 1;
Button1.Visible:=false;
Button2.Visible:=false;
Button3.Visible:=false;
Button4.Visible:=false;
Button5.Visible:=false;
Button6.Visible:=false;
Button7.Visible:=false;
Button8.Visible:=false;
Button9.Visible:=false;
Panel3.Visible:=false;
Panel4.Visible:=false;
Panel5.Visible:=false;
Panel6.Visible:=false;
end;
Label1.Caption := inttostr (Punkte1);
Label2.Caption := inttostr (Punkte2);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Spieler:=1;
Button1.Caption:='
';
Button2.Caption:='
';
Button3.Caption:='
';
Button4.Caption:='
';
Button5.Caption:='
';
Button6.Caption:='
';
Button7.Caption:='
';
Button8.Caption:='
';
Button9.Caption:='
';
Panel2.Caption:='
Klicken sie auf ein Spielfeld, um das Spiel zu starten.';
Panel2.Color:=clyellow;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button1.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button1.enabled:=false;
end
else
begin
Button1.Caption:='
O';
Button1.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button1.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button2.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button2.enabled:=false;
end
else
begin
Button2.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button2.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button3.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button3.enabled:=false;
end
else
begin
Button3.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button3.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button4.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button4.enabled:=false;
end
else
begin
Button4.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button4.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button5.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button5.enabled:=false;
end
else
begin
Button5.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button5.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button6.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button6.enabled:=false;
end
else
begin
Button6.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button6.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button7.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button7.enabled:=false;
end
else
begin
Button7.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button7.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.Button8Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button8.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button8.enabled:=false;
end
else
begin
Button8.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button8.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.Button9Click(Sender: TObject);
begin
if Spieler=1
then
begin
Button9.Caption:='
O';
Spieler:= 2;
Panel2.color:=cllime;
Panel2.caption:=Spieler2 + '
ist am Zug';
Button9.enabled:=false;
end
else
begin
Button9.Caption:='
X';
Spieler:= 1;
Panel2.color:=clred;
Panel2.caption:=Spieler1 + '
ist am Zug';
Button9.enabled:=false;
end;
Gewinner;
end;
procedure TForm1.FormActivate(Sender: TObject);
begin
Spieler1 := InputBox('
Spieler 1', '
Bitte gebe deinen Namen ein: ' , '
Spieler 1');
Spieler2 := InputBox('
Spieler 2', '
Bitte gebe deinen Namen ein: ' , '
Spieler 2');
LabelVs.Caption := Spieler1 + '
vs. ' + Spieler2;
end;
procedure TForm1.Button11Click(Sender: TObject);
begin
Button1.Caption:='
';
Button2.Caption:='
';
Button3.Caption:='
';
Button4.Caption:='
';
Button5.Caption:='
';
Button6.Caption:='
';
Button7.Caption:='
';
Button8.Caption:='
';
Button9.Caption:='
';
Panel2.Caption:='
Klicken sie auf ein Spielfeld, um das Spiel zu starten.';
Panel2.Color:=clyellow;
Button1.enabled:=true;
Button2.enabled:=true;
Button3.enabled:=true;
Button4.enabled:=true;
Button5.enabled:=true;
Button6.enabled:=true;
Button7.enabled:=true;
Button8.enabled:=true;
Button9.enabled:=true;
Button10.Visible:=false;
Button11.Visible:=false;
Panel3.Visible:=true;
Panel4.Visible:=true;
Panel5.Visible:=true;
Panel6.Visible:=true;
Button1.Visible:=true;
Button2.Visible:=true;
Button3.Visible:=true;
Button4.Visible:=true;
Button5.Visible:=true;
Button6.Visible:=true;
Button7.Visible:=true;
Button8.Visible:=true;
Button9.Visible:=true;
end;
procedure TForm1.Button10Click(Sender: TObject);
begin
form1.close;
end;
procedure TForm1.Orange1Click(Sender: TObject);
begin
Form1.Color:=$00ff00;
end;
procedure TForm1.Grau1Click(Sender: TObject);
begin
Form1.Color:=$717171;
end;
procedure TForm1.Lila1Click(Sender: TObject);
begin
Form1.Color:=$550055;
end;
procedure TForm1.Pink1Click(Sender: TObject);
begin
Form1.Color:=$FF00FF;
end;
procedure TForm1.Maroon1Click(Sender: TObject);
begin
Form1.Color:=$800000;
end;
procedure TForm1.Olive1Click(Sender: TObject);
begin
Form1.Color:=$808000;
end;
procedure TForm1.Trkise1Click(Sender: TObject);
begin
Form1.Color:=$40E0D0;
end;
end.