c mon 1er projet en delphi7 moi & mr.merzoug nous avons passer quatre jours pour le terminer
merci de donner votre avie sur ce jeu
Source / Exemple :
{ PROJET DE FIN D'ANNEE 2008/2009
réalisé par :
Mohamed Merzoug
&
Ahmedou Mohameden
}
unit Unit1;
interface
uses
Windows, SysUtils, Menus, StdCtrls, Controls, Grids, Classes;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button1: TButton;
MainMenu1: TMainMenu;
Fichier1: TMenuItem;
NouvellePartie1: TMenuItem;
N1: TMenuItem;
Quiter1: TMenuItem;
N2: TMenuItem;
Apropos1: TMenuItem;
Button2: TButton;
Label3: TLabel;
joueur: TLabel;
Button3: TButton;
Button4: TButton;
Edit3: TEdit;
Edit4: TEdit;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Button5: TButton;
Button6: TButton;
Button7: TButton;
procedure NouvellePartie1Click(Sender: TObject);
procedure Quiter1Click(Sender: TObject);
procedure Apropos1Click(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);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n1x,n1y,s1x,s1y,v,r,i,k,a,b,sp1x,sp1y,pnt1,n2x,n2y,s2x,s2y,sp2x,sp2y,pnt2:integer;
implementation
{$R *.dfm}
procedure TForm1.NouvellePartie1Click(Sender: TObject);
var i,j:integer;
begin
for i:=0 to 2 do
begin
for j:=0 to 7 do
begin
if ((i+j) mod 2)<>0 then
begin
StringGrid1.Cells[j,i]:='1';
end
else
StringGrid1.Cells[j,i]:=' ';
end;
end;
for i:=3 to 4 do
begin
for j:=0 to 7 do
begin
StringGrid1.Cells[j,i]:=' ';
end;
end;
for i:=5 to 7 do
begin
for j:=0 to 7 do
begin
if ((i+j) mod 2)<>0 then
begin
StringGrid1.Cells[j,i]:='2';
end
else
StringGrid1.Cells[j,i]:=' ';
end;
end;
Label1.Visible:=true;
Label2.Visible:=true;
Edit1.Visible:=true;
Edit2.Visible:=true;
Button1.Visible:=true;
joueur.Visible:=true;
label5.Visible:=true;
Label4.Visible:=true;
Edit3.Visible:=true;
Edit4.Visible:=true;
end;
procedure TForm1.Quiter1Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm1.Apropos1Click(Sender: TObject);
begin
showmessage(' °''--__ PROJET FIN D''ANNEE AHMEDOU MEDEN ET MED MERZOUG __--''° ');
end;
procedure initialisationpiont;
begin
pnt1:=0;
pnt2:=0;
end;
procedure TForm1.Button1Click(Sender: TObject );
begin
sp1x:=StrToInt(Edit1.Text);
sp1y:=StrToInt(Edit2.Text);
if (StringGrid1.Cells[sp1x,sp1y]='1')or(StringGrid1.Cells[sp1x,sp1y]='9') then
begin
Label1.Caption:='nouvelle Position de x:';
Label2.Caption:='nouvelle Position de y:';
Edit1.Text:='';
Edit2.Text:='';
Button2.Visible:=true;
Button1.Visible:=false;
Button6.Visible:=true;
s1x:=sp1x; s1y:=sp1y;
end
else
begin
showmessage(' ce n''est pas votre pion reprenner svp..');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
k:=0; r:=0;
n1x:=StrToInt(Edit1.Text);
n1y:=StrToInt(Edit2.Text);
if (n1x<0)or(n1x>7)or(n1y<0)or(n1y>7)then
begin showmessage(' saisie incourect reprenner svp..'); end
else
begin
if (StringGrid1.Cells[n1x,n1y]='1')or(StringGrid1.Cells[n1x,n1y]='2')or(StringGrid1.Cells[n1x,n1y]='8')or(StringGrid1.Cells[n1x,n1y]='9')then
begin
showmessage(' la case contient deja un pion reprenner svp..');
end
else
begin
if (Abs(s1x-n1x)<>Abs(s1y-n1y))then
begin
showmessage(' le deplacement autorisé sur le diagonal seulement reprenner svp..');
end
else
begin
if(StringGrid1.Cells[s1x,s1y]='1')then
begin
if(n1y<s1y)then
begin
if (n1x=s1x+2)and(n1y=s1y-2)and((StringGrid1.Cells[s1x+1,s1y-1]='2')or(StringGrid1.Cells[s1x+1,s1y-1]='8'))then
begin
StringGrid1.Cells[n1x,n1y]:='1';
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[s1x+1,s1y-1]:=' ';
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (n1x=s1x-2)and(n1y=s1y-2)and((StringGrid1.Cells[s1x-1,s1y-1]='2')or(StringGrid1.Cells[s1x-1,s1y-1]='8'))then
begin
StringGrid1.Cells[n1x,n1y]:='1';
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[s1x-1,s1y-1]:=' ';
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' reculement non autoriser reprenner svp..');
end;
end;
end
else
begin
if (s1y=6)and(n1y=7)then
begin
StringGrid1.Cells[n1x,n1y]:='9';
StringGrid1.Cells[s1x,s1y]:=' ';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if(s1y=5)and(n1y=7)and(n1x<s1x)and((StringGrid1.Cells[s1x-1,s1y+1]='2')or(StringGrid1.Cells[s1x-1,s1y+1]='8'))then
begin
StringGrid1.Cells[n1x,n1y]:='9';
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[s1x-1,s1y+1]:=' ';
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if(s1y=5)and(n1y=7)and((StringGrid1.Cells[s1x+1,s1y+1]='2')or(StringGrid1.Cells[s1x+1,s1y+1]='8'))then
begin
StringGrid1.Cells[n1x,n1y]:='9';
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[s1x+1,s1y+1]:=' ';
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if(n1y=s1y+1)then
begin
StringGrid1.Cells[n1x,n1y]:='1';
StringGrid1.Cells[s1x,s1y]:=' ';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if(n1x=s1x+2)and(n1y=s1y+2)then
begin
if (StringGrid1.Cells[s1x+1,s1y+1]='2')or(StringGrid1.Cells[s1x+1,s1y+1]='8')then
begin
StringGrid1.Cells[s1x+1,s1y+1]:=' ';
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[n1x,n1y]:='1';
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement impossible ');
end;
end
else
begin
if(n1x=s1x-2)and(n1y=s1y+2)then
begin
if (StringGrid1.Cells[s1x-1,s1y+1]='2')or(StringGrid1.Cells[s1x-1,s1y+1]='8')then
begin
StringGrid1.Cells[s1x-1,s1y+1]:=' ';
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[n1x,n1y]:='1';
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement impossible ');
end;
end
else
begin
if(n1y>s1y+2)then
begin
showmessage(' deplacement impossible ');
end;
end;
end;
end;
end;
end;
end;
end;
end
else
begin
if(StringGrid1.Cells[s1x,s1y]='9')then
begin
if(n1y<s1y)then
begin
if(n1x>s1x)then
begin
v:=n1x-s1x;
for i:=1 to v do
begin
if(StringGrid1.Cells[s1x+i,s1y-i]='2')or(StringGrid1.Cells[s1x+i,s1y-i]='8')then
begin
k:=k+1; a:=s1x+i; b:=s1y-i;
end
else
begin
if(StringGrid1.Cells[s1x+i,s1y-i]='1')or(StringGrid1.Cells[s1x+i,s1y-i]='9')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n1x,n1y]:='9'; k:=0;
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[n1x,n1y]:='9';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end
else
begin
if(n1x<s1x)then
begin
v:=Abs(s1x-n1x);
for i:=1 to v do
begin
if(StringGrid1.Cells[s1x-i,s1y-i]='2')or(StringGrid1.Cells[s1x-i,s1y-i]='8')then
begin
k:=k+1; a:=s1x-i; b:=s1y-i;
end
else
begin
if(StringGrid1.Cells[s1x-i,s1y-i]='1')or(StringGrid1.Cells[s1x-i,s1y-i]='9')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n1x,n1y]:='9';
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[n1x,n1y]:='9';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end;
end;
end
else
begin
if n1y>s1y then
begin
if(n1x>s1x)then
begin
v:=n1x-s1x;
for i:=1 to v do
begin
if(StringGrid1.Cells[s1x+i,s1y+i]='2')or(StringGrid1.Cells[s1x+i,s1y+i]='8')then
begin
k:=k+1; a:=s1x+i; b:=s1y+i;
end
else
begin
if(StringGrid1.Cells[s1x+i,s1y+i]='1')or(StringGrid1.Cells[s1x+i,s1y+i]='9')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n1x,n1y]:='9'; k:=0;
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[n1x,n1y]:='9';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end
else
begin
if(n1x<s1x)then
begin
v:=s1x-n1x;
for i:=1 to v do
begin
if(StringGrid1.Cells[s1x-i,s1y+i]='2')or(StringGrid1.Cells[s1x-i,s1y+i]='8')then
begin
k:=k+1; a:=s1x-i; b:=s1y+i;
end
else
begin
if(StringGrid1.Cells[s1x-i,s1y+i]='1')or(StringGrid1.Cells[s1x-i,s1y+i]='9')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n1x,n1y]:='9'; k:=0;
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[n1x,n1y]:='9';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end;
if(n1x<s1x)then
begin
v:=s1x-n1x;
for i:=1 to v do
begin
if(StringGrid1.Cells[s1x-i,s1y-i]='2')or(StringGrid1.Cells[s1x-i,s1y-i]='8')then
begin
k:=k+1; a:=s1x-i; b:=s1y-i;
end
else
begin
if(StringGrid1.Cells[s1x-i,s1y-i]='1')or(StringGrid1.Cells[s1x-i,s1y-i]='9')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n1x,n1y]:='9'; k:=0;
pnt1:=pnt1+1; Edit3.Text:=IntToStr(pnt1);
if (pnt1=12)then
begin
showmessage('BRAVO le joueur avec -1- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s1x,s1y]:=' ';
StringGrid1.Cells[n1x,n1y]:='9';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button2.Visible:=false;
Button3.Visible:=true;
Button6.Visible:=false;
Joueur.Caption:='Joueur avec 2:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
sp2x:=StrToInt(Edit1.Text);
sp2y:=StrToInt(Edit2.Text);
if (StringGrid1.Cells[sp2x,sp2y]='2')or(StringGrid1.Cells[sp2x,sp2y]='8') then
begin
Label1.Caption:='nouvelle Position de x:';
Label2.Caption:='nouvelle Position de y:';
Edit1.Text:='';
Edit2.Text:='';
Button4.Visible:=true;
Button3.Visible:=false;
Button7.Visible:=true;
s2x:=sp2x; s2y:=sp2y;
end
else
begin
showmessage(' ce n''est pas votre pion reprenner svp..');
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
k:=0; r:=0;
n2x:=StrToInt(Edit1.Text);
n2y:=StrToInt(Edit2.Text);
if (n2x<0)or(n2x>7)or(n2y<0)or(n2y>7)then
begin showmessage(' saisie incorect reprenner svp..'); end
else
begin
if (StringGrid1.Cells[n2x,n2y]='1')or(StringGrid1.Cells[n2x,n2y]='2')or(StringGrid1.Cells[n2x,n2y]='9')or(StringGrid1.Cells[n2x,n2y]='8')then
begin
showmessage(' la case contient deja un pion reprenner svp..');
end
else
begin
if (Abs(s2x-n2x)<>Abs(s2y-n2y))then
begin
showmessage(' le deplacement autorisé sur le diagonal seulement reprenner svp..');
end
else
begin
if(StringGrid1.Cells[s2x,s2y]='2')then
begin
if(n2y>s2y)then
begin
if (n2x=s2x+2)and(n2y=s2y+2)and((StringGrid1.Cells[s2x+1,s2y+1]='1')or(StringGrid1.Cells[s2x+1,s2y+1]='9'))then
begin
StringGrid1.Cells[n2x,n2y]:='2';
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[s2x+1,s2y+1]:=' ';
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (n2x=s2x-2)and(n2y=s2y+2)and((StringGrid1.Cells[s2x-1,s2y+1]='1')or(StringGrid1.Cells[s2x-1,s2y+1]='9'))then
begin
StringGrid1.Cells[n2x,n2y]:='2';
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[s2x-1,s2y+1]:=' ';
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' reculement non autoriser reprenner svp..');
end;
end;
end
else
begin
if (s2y=1)and(n2y=0)then
begin
StringGrid1.Cells[n2x,n2y]:='8';
StringGrid1.Cells[s2x,s2y]:=' ';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if(s2y=2)and(n2y=0)and(n2x<s2x)and((StringGrid1.Cells[s2x-1,s2y-1]='1')or(StringGrid1.Cells[s2x-1,s2y-1]='9'))then
begin
StringGrid1.Cells[n2x,n2y]:='8';
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[s2x-1,s2y-1]:=' ';
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if(s2y=2)and(n2y=0)and((StringGrid1.Cells[s2x+1,s2y-1]='1')or(StringGrid1.Cells[s2x+1,s2y-1]='9'))then
begin
StringGrid1.Cells[n2x,n2y]:='8';
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[s2x+1,s2y-1]:=' ';
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
if(n2y=s2y-1)then
begin
StringGrid1.Cells[n2x,n2y]:='2';
StringGrid1.Cells[s2x,s2y]:=' ';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if(n2x=s2x+2)and(n2y=s2y-2)then
begin
if (StringGrid1.Cells[s2x+1,s2y-1]='1')or(StringGrid1.Cells[s2x+1,s2y-1]='9')then
begin
StringGrid1.Cells[s2x+1,s2y-1]:=' ';
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[n2x,n2y]:='2';
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement impossible ');
end;
end
else
begin
if(n2x=s2x-2)and(n2y=s2y-2)then
begin
if (StringGrid1.Cells[s2x-1,s2y-1]='1')or(StringGrid1.Cells[s2x-1,s2y-1]='9')then
begin
StringGrid1.Cells[s2x-1,s2y-1]:=' ';
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[n2x,n2y]:='2';
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement impossible ');
end;
end
else
begin
if(n2y<s1y-2)then
begin
showmessage(' deplacement impossible ');
end;
end;
end;
end;
end;
end;
end;
end
else
begin
if(StringGrid1.Cells[s2x,s2y]='8')then
begin
if(n2y<s2y)then
begin
if(n2x>s2x)then
begin
v:=n2x-s2x;
for i:=1 to v do
begin
if(StringGrid1.Cells[s2x+i,s2y-i]='1')or(StringGrid1.Cells[s2x+i,s2y-i]='9')then
begin
k:=k+1; a:=s2x+i; b:=s2y-i;
end
else
begin
if(StringGrid1.Cells[s2x+i,s2y-i]='2')or(StringGrid1.Cells[s2x+i,s2y-i]='8')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n2x,n2y]:='8'; k:=0;
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[n2x,n2y]:='8';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end
else
begin
if(n2x<s2x)then
begin
v:=s2x-n2x;
for i:=1 to v do
begin
if(StringGrid1.Cells[s2x-i,s2y-i]='1')or(StringGrid1.Cells[s2x-i,s2y-i]='9')then
begin
k:=k+1; a:=s2x-i; b:=s2y-i;
end
else
begin
if(StringGrid1.Cells[s2x-i,s2y-i]='2')or(StringGrid1.Cells[s2x-i,s2y-i]='8')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n2x,n2y]:='8'; k:=0;
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[n2x,n2y]:='8';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end;
end;
end
else
begin
if n2y>s2y then
begin
if(n2x>s2x)then
begin
v:=n2x-s2x;
for i:=1 to v do
begin
if(StringGrid1.Cells[s2x+i,s2y+i]='1')or(StringGrid1.Cells[s2x+i,s2y+i]='9')then
begin
k:=k+1; a:=s2x+i; b:=s2y+i;
end
else
begin
if(StringGrid1.Cells[s2x+i,s2y+i]='2')or(StringGrid1.Cells[s2x+i,s2y+i]='8')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n2x,n2y]:='8'; k:=0;
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[n2x,n2y]:='8';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end
else
begin
if(n2x<s2x)then
begin
v:=s2x-n2x;
for i:=1 to v do
begin
if(StringGrid1.Cells[s2x-i,s2y+i]='1')or(StringGrid1.Cells[s2x-i,s2y+i]='9')then
begin
k:=k+1; a:=s2x-i; b:=s2y+i;
end
else
begin
if(StringGrid1.Cells[s2x-i,s2y+i]='2')or(StringGrid1.Cells[s2x-i,s2y+i]='8')then
begin
r:=1;
end;
end;
end;
if (k=1) and (r=0) then
begin
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[a,b]:=' ';
StringGrid1.Cells[n2x,n2y]:='8'; k:=0;
pnt2:=pnt2+1; Edit4.Text:=IntToStr(pnt2);
if (pnt2=12)then
begin
showmessage('BRAVO le joueur avec -2- a gagné ');
end;
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
if (k=0) and (r=0) then
begin
StringGrid1.Cells[s2x,s2y]:=' ';
StringGrid1.Cells[n2x,n2y]:='8';
Label1.caption:='donner la position de x:';
Label2.caption:='donner la position de y:';
Button4.Visible:=false;
Button1.Visible:=true;
Button7.Visible:=false;
Joueur.Caption:='Joueur avec 1:';
Edit1.Text:='';
Edit2.Text:='';
end
else
begin
showmessage(' deplacement non autorisé reprenner svp...'); k:=0; r:=0;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
end;
procedure TForm1.Button5Click(Sender: TObject);
begin
application.Terminate;
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
Button1.Visible:=true;
Button2.Visible:=false;
Label1.Caption:='donner la position de x:';
Label2.Caption:='donner la position de y:';
Edit1.Text:='';
Edit2.Text:='';
Button6.Visible:=false;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
Button3.Visible:=true;
Button4.Visible:=false;
Label1.Caption:='donner la position de x:';
Label2.Caption:='donner la position de y:';
Edit1.Text:='';
Edit2.Text:='';
Button7.Visible:=false;
end;
end.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.