1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
type TGameArray = array of array of integer;
const
L = 9; //Ligne
C = 9;//Colone
M = 10;//Nombre de mine
var Table:TGameArray;//Table de jeu
//Alors la vienne les procedure et fonctions qui initialise le jeu et tout
....
//Le joueur click sur une cellule
procedure TForm1.GrilleSelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
begin
case Table[ARow,ACol] of // selon le nombre se trouvant dans le tableau
8://Grille.Cells[ACol,ARow] := ' ';// 8 designe un blanc
KillBlanks (ARow, ACol); // j'affiche tout les blanc voisins
0:Grille.Cells[ACol,ARow] := 'O';//0 designe une mine
else
Grille.Cells[ACol,ARow] := inttostr(Table[ARow,ACol]);
end (*case*)
end;
//et voila la procedure KillBlank
procedure TForm1.KillBlanks (Row,Col:integer);
var MinesNbr:integer;
begin
Grille.Cells[Col,Row] := ' ';//J'affiche le blanc actuel
// je traite les cases voisines
if Row > 0 then
begin
if Col + 1 < C then
if Table[Row-1,Col+1] = 8 then
KillBlanks(Row-1,Col+1)
else
Grille.Cells[Col+1,Row-1]:=inttostr(Table[Row-1,Col+1]);
if Table[Row-1,Col] = 8 then
KillBlanks(Row-1,Col)
else
Grille.Cells[Col,Row-1]:=inttostr(Table[Row-1,Col]);
if Col - 1 > 0 then
if Table[Row-1,Col-1] = 8 then
KillBlanks(Row-1,Col-1)
else
Grille.Cells[Col-1,Row-1]:=inttostr(Table[Row-1,Col-1]);
end;(*Row>0*)
if Row < (L-1) then
begin
if Col + 1 < C then
if Table[Row+1,Col+1] = 8 then
KillBlanks(Row+1,Col+1)
else
Grille.Cells[Col+1,Row+1]:=inttostr(Table[Row+1,Col+1]);
if Table[Row+1,Col] = 8 then
KillBlanks(Row+1,Col)
else
Grille.Cells[Col,Row+1]:=inttostr(Table[Row+1,Col]);
if Col - 1 > 0 then
if Table[Row+1,Col-1] = 8 then
KillBlanks(Row+1,Col-1)
else
Grille.Cells[Col-1,Row+1]:=inttostr(Table[Row+1,Col-1]);
end;(*Row<L-1*)
if Col < (C-1) then
if Table[Row,Col+1] = 8 then
KillBlanks(Row,Col+1)
else
Grille.Cells[Col+1,Row]:=inttostr(Table[Row,Col+1]);
if Col > 0 then
if Table[Row, Col-1] = 8 then
KillBlanks(Row,Col-1)
else
Grille.Cells[Col-1,Row]:=inttostr(Table[Row,Col-1]);
end;(*KillBlanks*) |
Partager