Автор работы: Пользователь скрыл имя, 26 Октября 2010 в 17:19, Не определен
Игрушка, созданная на языке Delphi
Panel1: TPanel;
Image1: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label25: TLabel;
Panel2: TPanel;
Image2: TImage;
Label13: TLabel;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Label21: TLabel;
Label22: TLabel;
Label23: TLabel;
Label26: TLabel;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N6: TMenuItem;
N5: TMenuItem;
Label12: TLabel;
Label24: TLabel;
Label27: TLabel;
Label28: TLabel;
Label29: TLabel;
procedure FormCreate(Sender: TObject);
procedure rastkor(Sender: TObject; Shift: TShiftState; X, Y: Integer);
procedure nash(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure N2Click(Sender: TObject);
procedure vistrel(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure N3Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure N6Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
i,j,g,x1,y1,k11,k21,
k33,k32,k31,m3,m2,m1,
m,n,z:integer;
rot, //ротация кораблей
riad,rnd,
//для того что бы рядом не
ставились,нужна для
win,lose,
//проверка на победу или
bum, //проверка выстрела компьютера
kon, //проверка конца игры
cokil: boolean; //попал ли комрьютер
b1,b2:Array[1..14,1..14] of integer;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
rot:=false; //заполнение переменных
kon:=false;
k11:=3;
k33:=2;
k32:=5;
k31:=9;
m3:=0;
m2:=0;
m1:=0;
label13.Height:=0;
label14.Height:=0;
label15.Height:=0;
label16.Height:=0;
label17.Height:=0;
label18.Height:=0;
label19.Height:=0;
label20.Height:=0;
label21.Height:=0;
label22.Height:=0;
label23.Height:=0;
label26.Height:=0;
label12.Caption:='Расставьте корабли';
For i:=1 to 10 do //рисует сетку поля игрока
for j:=1 to 10 do
begin
b1[i,j]:=0;
image1.Canvas.Rectangle(20*i-
end;
randomize;
m:=random(10)+1;
n:=random(10)+1;
z:=(random(100)
mod 2);
//расстановка
клораблей компьютера
//четырехпалубный
case n of
1..7:
case m of
1..7: for i:=0 to 3 do
if z=0 then
b2[m+i,n]:=2
else
b2[m,n+i]:=2;
8..10: for i:=0 to 3 do
if z=0 then
b2[m-i,n]:=2
else
b2[m,n+i]:=2;
end;
8..10:
case m of
1..7: for i:=0 to 3 do
if z=0 then
b2[m+i,n]:=2
else
b2[m,n-i]:=2;
8..10: for i:=0 to 3 do
if z=0 then
b2[m-i,n]:=2
else
b2[m,n-i]:=2;
end;
end;
//трехпалубные
while m3<2 do begin
m:=random(10)+1;
n:=random(10)+1;
z:=(random(100)
mod 2);
case n of
1..7:
case m of
1..7: case z of
0: if (b2[m,n]<>2) and
(b2[m-1,n-1]<>2) and
(b2[m-1,n]<>2) and
(b2[m-1,n+1]<>2) and
(b2[m,n-1]<>2)and
(b2[m+1,n+1]<>2)and
(b2[m+1,n]<>2) and
(b2[m+1,n-1]<>2) and
(b2[m,n+1]<>2) and
(b2[m+1,n+2]<>2) and
(b2[m-1,n+2]<>2) and
(b2[m,n+2]<>2) and
(b2[m+1,n+3]<>2) and
(b2[m-1,n+3]<>2) and
(b2[m,n+3]<>2) and
(b2[m,n+3]<>2) then
begin
for i:=0 to 2 do
b2[m,n+i]:=2;
m3:=m3+1
end;
1: if (b2[m,n]<>2) and
(b2[m+1,n+1]<>2) and
(b2[m,n+1]<>2) and
(b2[m-1,n+1]<>2) and
(b2[m-1,n]<>2)and
(b2[m-1,n-1]<>2)and
(b2[m,n-1]<>2) and
(b2[m+1,n-1]<>2) and
(b2[m+1,n]<>2) and
(b2[m+2,n-1]<>2) and
(b2[m+2,n+1]<>2) and
(b2[m+2,n]<>2) and
(b2[m+3,n-1]<>2) and
(b2[m+3,n+1]<>2) and
(b2[m+3,n]<>2) and
(b2[m+3,n]<>2) then begin
for i:=0 to 2 do
b2[m+i,n]:=2;
m3:=m3+1
end;
8..10: case z of
0: if (b2[m,n]<>2) and
(b2[m+1,n+1]<>2) and
(b2[m,n+1]<>2) and
(b2[m-1,n+1]<>2) and
(b2[m-1,n]<>2)and
(b2[m-1,n-1]<>2)and
(b2[m,n-1]<>2) and
(b2[m+1,n-1]<>2) and
(b2[m-2,n-1]<>2) and
(b2[m-2,n+1]<>2) and
(b2[m-2,n]<>2) and
(b2[m-3,n-1]<>2) and
(b2[m-3,n+1]<>2) and
(b2[m-3,n]<>2) then
begin
for i:=0 to 2 do
b2[m-i,n]:=2;
m3:=m3+1
end;
1: if (b2[m,n]<>2) and
(b2[m-1,n-1]<>2) and
(b2[m-1,n]<>2) and
(b2[m-1,n+1]<>2) and
(b2[m,n-1]<>2)and
(b2[m+1,n+1]<>2)and
(b2[m+1,n]<>2) and
(b2[m+1,n-1]<>2) and
(b2[m,n+1]<>2) and