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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
| library newdll;
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Menus, StdCtrls,
FormShowAbout;
{$R *.res}
type
TForm1 = class(TForm)
mm1: TMainMenu;
N1: TMenuItem;
Label1: TLabel;
N2: TMenuItem;
N3: TMenuItem;
procedure N1Click(Sender: TObject);
procedure ImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure N3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
img:array[1..7,1..7] of TImage;
min1array:array[1..49] of Boolean;
min2array:array[1..7,1..7] of Boolean;
minanear:array[1..7,1..7] of Byte;
minaflag:array[1..7,1..7] of Boolean;
opened:array[1..7,1..7] of Boolean;
sum : Integer;
stopgame: Boolean;
procedure TForm1.N3Click(Sender: TObject);
begin
ShowAbout(Handle);
end;
procedure TForm1.N1Click(Sender: TObject);
var i,j:Integer;
begin
stopgame := False;
sum:=0;
Label1.Caption:='Èãðà Íà÷àëàñü!';
for i := 1 to 7 do
begin
for j := 1 to 7 do
begin
Img[i,j] := TImage.Create(Self);
Img[i,j].Parent := Self;
Img[i,j].Left := i*40;
Img[i,j].Top := j*40;
Img[i,j].Width := 33;
Img[i,j].Height := 33;
Img[i,j].Picture.LoadFromFile('start.bmp');
img[i,j].OnMouseDown:=ImageMouseDown;
img[i,j].Tag := j*7-7+i;
if Random(3) = 0
then min2array[i,j]:= True
else min2array[i,j]:= False;
min1array[j*7-7+i]:=min2array[i,j];
minanear[i,j]:=0;
minaflag[i,j]:=False;
opened[i,j]:=False;
end;
end;
for i := 1 to 7 do
begin
for j := 1 to 7 do
begin
if (i-1>0) and (j-1>0) then if min2array[i-1,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
if i-1>0 then if min2array[i-1,j] = True then minanear[i,j]:=minanear[i,j]+1;
if (i-1>0) and (j+1<8) then if min2array[i-1,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
if j-1>0 then if min2array[i,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
if j+1<8 then if min2array[i,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
if (i+1<8) and (j-1>0) then if min2array[i+1,j-1] = True then minanear[i,j]:=minanear[i,j]+1;
if i+1<8 then if min2array[i+1,j] = True then minanear[i,j]:=minanear[i,j]+1;
if (i+1<8) and (j+1<8) then if min2array[i+1,j+1] = True then minanear[i,j]:=minanear[i,j]+1;
end;
end;
end;
procedure TForm1.ImageMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var i,j:Integer;
begin
if stopgame = False
then
begin
If Button = mbLeft then
with Sender as TImage do
begin
if min1array[Tag] = True
then
begin
for i := 1 to 7 do
begin
for j := 1 to 7 do
begin
if min2array[i,j] = True
then Img[i,j].Picture.LoadFromFile('bomb.bmp');
end;
end;
Label1.Caption:='Ïðîèãðûø!';
stopgame := True;
end
else
begin
i:= Tag div 7+1;
j:= Tag mod 7;
if j = 0
then
begin
j:=7; i:=i-1
end;
Img[j,i].Picture.LoadFromFile(IntToStr(minanear[j,i])+'.bmp');
opened[i,j] := True;
end;
end;
If Button = mbRight then
with Sender as TImage do
begin
i:= Tag div 7+1;
j:= Tag mod 7;
if j = 0 then
begin
j:=7; i:=i-1
end;
if opened[i,j] = False then
begin
if minaflag[j,i] = false
then
begin
minaflag[j,i] := True;
Img[j,i].Picture.LoadFromFile('flag.bmp');
end
else
begin
minaflag[j,i] := False;
Img[j,i].Picture.LoadFromFile('start.bmp');
end;
for i := 1 to 7 do
begin
for j := 1 to 7 do
begin
if minaflag[i,j]=min2array[i,j] then
sum:=sum+1;
end;
end;
if sum = 49 then
begin
stopgame := True;
Label1.Caption:='Ïîáåäà!';
end
else sum:=0;
end;
end;
end;
end;
exports ShowAbout;
begin
stopgame := False;
sum := 0;
end. |