Пояснительная записка

Программа реализует классическую игру «Морской бой». Целью данной игры является уничтожение всех кораблей противника, расположенных на правом поле, он (противник) будет уничтожать Ваши корабли на левом поле.

В начале игры выбирается схема (количество кораблей, тип (пример схемы - F3)), далее расстановка на "поле боя", причем, корабли не должны соприкасаться углами или сторонами. Левая кнопка мыши - поставить корабль, правая - повернуть на 90 градусов. Далее предоставляется право выбора первого удара. Ходы делаются поочерёдно, при попадании делается следующий ход. И так до чьей-либо победы.

Также реализовано действие горячих клавиш:

F1  – новая игра, счетчик результатов не обнуляется;

F3  - пример расположения кораблей выбранной схемы на левой панели;

F4  - карта расположения кораблей;

F5  - позиция последних ударов  с обеих сторон;

F6  - скрыть расположение своих кораблей после расстановки;

F7  - показать расположение своих кораблей;

CTRL F1 – выбрать схему ”Бой”;

CTRL F2 – выбрать схему ”Школа”;

CTRL F3 – выбрать схему ”Окна”;

F12 – выход из игры.

Далее приведен код программы с комментариями:

//---------------------------------------------------------------------------

#include <vcl.h>

#pragma hdrstop

#include "shipsu.h"

//---------------------------------------------------------------------------

#pragma package(smart_init)

#pragma link "CSPIN"

#pragma resource "*.dfm"

#include "AboutForm.cpp"

//---------------------------------------------------------------------------

TForm1 *Form1;

//-------------------------------------------------------------

__fastcall TForm1::TForm1(TComponent* Owner)

            : TForm(Owner)

{

}

//---------------------------------------------------------------------------

void __fastcall TForm1::side_x(int x,int y,int a,int b,int c,int d,int f)

{

            if ( x>=a )

            {

                        comp.put_bit(x+b,y,3);

            }

            comp.put_bit(x+c, y,3);

            IComp->Canvas->Draw((x+d)*25,y*25,BitMapm);

            IComp->Canvas->Draw((x+f)*25,y*25,BitMapm);

}

void __fastcall TForm1::side_y(int x,int y,int a,int b,int c,int d,int g)

{

            if ( y>=a )

            {

                        comp.put_bit(x,y+b,3);

            }

            comp.put_bit(x, y+c, 3);

            IComp->Canvas->Draw(x*25,(y+d)*25,BitMapm);

            IComp->Canvas->Draw(x*25,(y+g)*25,BitMapm);

}

void __fastcall TForm1::side(int x, int y, int control)

{

            int vector_free2_w=0;

            int vector_free3_w=0;

            int vector_free2_o=0;

            int vector_free3_o=0;

            int vector_free2_n=0;

            int vector_free3_n=0;

            int vector_free2_s=0;

            int vector_free3_s=0;

            int vect_w=0;  // для выбора направления по массиву

            int vect_n=0;   // для выбора направления по массиву

            int vect_o=0;   // для выбора направления по массиву

            int vect_s=0;    // для выбора направления по массиву

            int vect_1w=0; // для выбора направления по массиву

            int vect_1n=0; // для выбора направления по массиву

            int vect_1o=0; // для выбора направления по массиву

            int vect_1s=0;  // для выбора направления по массиву

            int vect_2w=0; // для выбора направления по массиву

            int vect_2n=0; // для выбора направления по массиву

            int vect_2o=0; // для выбора направления по массиву

            int vect_2s=0;  // для выбора направления по массиву

            int array_around[12][2]={{ 0,-1},

                                                                                  { 0,-2},

                                                                                  { 0,-3},

                                                                                  { 0, 1},            //          3 3         3 3       3 3       3 3                               3 3

                                                                                  { 0, 2},            //

                                                                                  { 0, 3},            //  1 2 * 0  1 2 * 3  3 2 * 0  3 2 * 1                   3 2 * 0

                                                                                  {-1, 0},                        //          0 3         0 3       0 3       0 3                               0 3

                                                                                  {-2, 0},                        //

                                                                                  {-3, 0},

                                                                                  { 1, 0},

                                                                                  { 2, 0},

                                                                                  { 3, 0}};

            vect_12_wm=0;            // 1 max 1

            vect_13_wm=0;

            vect_14_wm=0;

            vect_12_om=0;

            vect_13_om=0;

            vect_14_om=0;

            vect_12_nm=0;

            vect_13_nm=0;

            vect_14_nm=0;

            vect_12_sm=0;

            vect_13_sm=0;

            vect_14_sm=0;

            for ( int i=0;i<12;i++ )

            {

                        if ( comp.show_bit(x+array_around[i][1],y+array_around[i][0])==1 )

                        {

                                   switch ( i )                                                      //

                                   {

                                               case 0:

                                                                       vect_12_wm++;

                                                                       break;

                                               case 1:

                                                                       vect_13_wm++;

                                                                       break;

                                               case 2:

                                                                       vect_14_wm++;

                                                                       break;

                                               case 3:

                                                                       vect_12_om++;

                                                                       break;

                                               case 4:

                                                                       vect_13_om++;

                                                                       break;

                                               case 5:

                                                                       vect_14_om++;

                                                                       break;

                                               case 6:

                                                                       vect_12_nm++;

                                                                       break;

                                               case 7:

                                                                       vect_13_nm++;

                                                                       break;

                                               case 8:

                                                                       vect_14_nm++;

                                                                       break;

                                               case 9:

                                                                       vect_12_sm++;

                                                                       break;

                                               case 10:

                                                                       vect_13_sm++;

                                                                       break;

                                               case 11:

                                                                       vect_14_sm++;

                                   }

                        }

                        if ( comp.show_bit(x+array_around[i][1],y+array_around[i][0])==2 )

                        {

                                   switch ( i )

                                   {

                                               case 0:

                                                                       vect_1w++;

                                               case 1:

                                                                       vect_2w++;

                                               case 2:

                                                                       vect_w++;

                                                                       break;

                                               case 3:

                                                                       vect_1o++;

                                               case 4:

                                                                       vect_2o++;

                                               case 5:

                                                                       vect_o++;

                                                                       break;

                                               case 6:

                                                                       vect_1n++;

                                               case 7:

                                                                       vect_2n++;

                                               case 8:

                                                                       vect_n++;

                                                                       break;

                                               case 9:

                                                                       vect_1s++;

                                               case 10:

                                                                       vect_2s++;

                                               case 11:

                                                                       vect_s++;

                                   }

                        }

                        if ( comp.show_bit(x+array_around[i][1],y+array_around[i][0])==0||comp.show_bit(x+array_around[i][1],y+array_around[i][0])==3 )

                        {

                                   switch ( i )

                                   {

                                               case 0:

                                                                       vector_free2_w++;

                                                                       break;

                                               case 1:

                                                                       vector_free3_w++;

                                                                       break;

                                               case 3:

                                                                       vector_free2_o++;

                                                                       break;

                                               case 4:

                                                                       vector_free3_o++;

                                                                       break;

                                               case 6:

                                                                       vector_free2_n++;

                                                                       break;

                                               case 7:

                                                                       vector_free3_n++;

                                                                       break;

                                               case 9:

                                                                       vector_free2_s++;

                                                                       break;

                                               case 10:

                                                                       vector_free3_s++;

                                                                       break;

                                               default: ;

                                               }

                        }

            }

            if (!RadarOFF1->Checked)

            {

                        paint_radar_man();

            }

            if (control)

            {

                        if ( vector_free2_w==1&&vector_free2_n==1&&vector_free2_o==1&&vector_free2_s==1) // фигура 1 клетка

                        {

                                   side_x(x,y,1,-1,1,-1,1);

                                   side_y(x,y,1,-1,1,-1,1);

                        }

                        else if ( vect_w==3 )   // фигура 4 клетки  на оду сторону

                        {

                                   side_x(x,y,4,-4,1,-4,1);

                        }

                        else if ( vect_o==3 )    // фигура 4 клетки  на оду сторону

                        {

                                   side_x(x,y,1,-1,4,-1,4);

                        }

                        else if ( vect_n==3 )    // фигура 4 клетки  на оду сторону

                        {

                                   side_y(x,y,4,-4,1,1,-4);

                        }

                        else if ( vect_s==3 )    // фигура 4 клетки  на оду сторону

                        {

                                   side_y(x,y,1,-1,4,-1,4);

                        }

                        else if ( vect_2o==2&&vect_1w==1 )            // фигура 4 клетки со смещением направо

                        { //1011

                                   side_x(x,y,2,-2,3,-2,3);

                        }

                        else if ( vect_2w==2&&vect_1o==1 )            // фигура 4 клетки со смещением налево

                        {

                                   side_x(x,y,3,-3,2,-3,2);

                        }

                        else if ( vect_2n==2&&vect_1s==1 ) // фигура 4 клетки со смещением вверх

                        {

                                   side_y(x,y,3,-3,2,2,-3);

                        }

                        else if ( vect_2s==2&&vect_1n==1 ) // фигура 4 клетки со смещением вниз

                        {

                                   side_y(x,y,2,-2,3,-2,3);

                        }

                        else if ( vect_2w==2&&vector_free2_o==1&&vect_14_wm==0 )   // фигура 3 клетки  на оду сторону

                        {

                                   side_x(x,y,3,-3,1,-3,1);

                        }

                        else if ( vect_2o==2&&vector_free2_w==1&&vect_14_om==0 )    // фигура 3 клетки  на оду сторону

                        {

                                   side_x(x,y,1,-1,3,-1,3);

                        }

                        else if ( vect_2n==2&&vector_free2_s==1&&vect_14_nm==0 )     // фигура 3 клетки  на оду сторону

                        {

                                   side_y(x,y,3,-3,1,1,-3);

                        }

                        else if ( vect_2s==2&&vector_free2_n==1&&vect_14_sm==0 )      // фигура 3 клетки  на оду сторону

                        {

                                   side_y(x,y,1,-1,3,-1,3);

                        }

                        else if ( vect_1w==1&&vect_1o==1&&vector_free3_w==1&&vector_free3_o==1 ) // фигура 3 клетки по 1 на две стороны

                        {  //101

                                   side_x(x,y,2,-2,2,-2,2);

                        }

                        else if ( vect_1n==1&&vect_1s==1&&vector_free3_n==1&&vector_free3_s==1 ) // фигура 3 клетки по 1 на две стороны

                        {  //101

                                   side_y(x,y,2,-2,2,-2,2);

                        }

                        else if ( vect_1w==1&&vector_free2_o==1&&vector_free3_w==1 ) // фигура 2 клетки

                        {

                                   side_x(x,y,2,-2,1,-2,1);

                        }

                        else if ( vect_1o==1&&vector_free2_w==1&&vector_free3_o==1 ) // фигура 2 клетки

                        {

                                   side_x(x,y,1,-1,2,-1,2);

                        }

                        else if ( vect_1n==1&&vector_free2_s==1&&vector_free3_n==1 ) // фигура 2 клетки

                        {

                                   side_y(x,y,2,-2,1,1,-2);

                        }

                        else if ( vect_1s==1&&vector_free2_n==1&&vector_free3_s==1 ) // фигура 2 клетки

                        {

                                   side_y(x,y,1,-1,2,-1,2);

                        }

            }

}

void __fastcall TForm1::review(int x, int y)

{

            int array_around[4][2]={{-1,-1},

                                                             {-1, 1},

                                                             { 1, 1},

                                                             { 1,-1}};

            if ( y==0&&x==0 )

            {

                        comp.put_bit(x+array_around[2][0],y+array_around[2][0],3);

                        IComp->Canvas->Draw((x+array_around[2][0])*25,(y+array_around[2][0])*25,BitMapm);

            }

            else if ( y==9&&x==0 )

            {

                        comp.put_bit(x+array_around[2][0],y+array_around[1][0],3);

                        IComp->Canvas->Draw((x+array_around[2][0])*25,(y+array_around[1][0])*25,BitMapm);

            }

            else if ( y==9&&x==9 )

            {

                        comp.put_bit(x+array_around[1][0],y+array_around[1][0],3);

                        IComp->Canvas->Draw((x+array_around[1][0])*25,(y+array_around[1][0])*25,BitMapm);

            }

            else if ( y==0&&x==9 )

            {

                        comp.put_bit(x+array_around[1][0],y+array_around[2][0],3);

                        IComp->Canvas->Draw((x+array_around[1][0])*25,(y+array_around[2][0])*25,BitMapm);

            }

            else if ( y==0 )

            {

                        for ( int i=2;i<4;i++ )   //расставили по углам 3 в массиве

                        {

                                   comp.put_bit(x+array_around[i][1],y+array_around[i][0],3);

                                   IComp->Canvas->Draw((x+array_around[i][1])*25,(y+array_around[i][0])*25,BitMapm);

                        }

            }

            else if ( x==0 )

            {

                        for ( int i=1;i<3;i++ )   //расставили по углам 3 в массиве

                        {

                                   comp.put_bit(x+array_around[i][1],y+array_around[i][0],3);

                                   IComp->Canvas->Draw((x+array_around[i][1])*25,(y+array_around[i][0])*25,BitMapm);

                        }

            }

            else

            {

                        for ( int i=0;i<4;i++ )   //расставили по углам 3 в массиве

                        {

                                   comp.put_bit(x+array_around[i][1],y+array_around[i][0],3);

                                   IComp->Canvas->Draw((x+array_around[i][1])*25,(y+array_around[i][0])*25,BitMapm);

                        }

            }

}

//----------------------------------------------------------------

void __fastcall TForm1::mside_x(int x,int y,int a,int b,int c,int d,int f)

{

            side_x_y=1;

            if ( x>=a )

            {

                        man.put_bit(x+b,y,3);

            }

            man.put_bit(x+c, y,3);

            IMan->Canvas->Draw((x+d)*25,y*25,BitMapm);

            IMan->Canvas->Draw((x+f)*25,y*25,BitMapm);

}

void __fastcall TForm1::mside_y(int x,int y,int a,int b,int c,int d,int g)

{

            side_x_y=1;

            if ( y>=a )

            {

                        man.put_bit(x,y+b,3);

            }

            man.put_bit(x, y+c, 3);

            IMan->Canvas->Draw(x*25,(y+d)*25,BitMapm);

            IMan->Canvas->Draw(x*25,(y+g)*25,BitMapm);

}

void __fastcall TForm1::mside(int x, int y, int control)

{

            int vector_free2_w=0;

            int vector_free3_w=0;

            int vector_free2_o=0;

            int vector_free3_o=0;

            int vector_free2_n=0;

            int vector_free3_n=0;

            int vector_free2_s=0;

            int vector_free3_s=0;

            int vect_w=0;  // для выбора направления по массиву

            int vect_n=0;   // для выбора направления по массиву

            int vect_o=0;   // для выбора направления по массиву

            int vect_s=0;    // для выбора направления по массиву

            int vect_1w=0; // для выбора направления по массиву

            int vect_1n=0; // для выбора направления по массиву

            int vect_1o=0; // для выбора направления по массиву

            int vect_1s=0;  // для выбора направления по массиву

            int vect_2w=0; // для выбора направления по массиву

            int vect_2n=0; // для выбора направления по массиву

            int vect_2o=0; // для выбора направления по массиву

            int vect_2s=0;  // для выбора направления по массиву

                        if ( vector_free2_w==1&&vector_free2_n==1&&vector_free2_o==1&&vector_free2_s==1) // фигура 1 клетка

                        {

                                   mside_x(x,y,1,-1,1,-1,1);

                                   mside_y(x,y,1,-1,1,-1,1);

                        }

                        else if ( vect_w==3 )   // фигура 4 клетки  на оду сторону

                        {

                                   mside_x(x,y,4,-4,1,-4,1);

                        }

                        else if ( vect_o==3 )    // фигура 4 клетки  на оду сторону

                        {

                                   mside_x(x,y,1,-1,4,-1,4);

                        }

                        else if ( vect_n==3 )    // фигура 4 клетки  на оду сторону

                        {

                                   mside_y(x,y,4,-4,1,1,-4);

                        }

                        else if ( vect_s==3 )    // фигура 4 клетки  на оду сторону

                        {

                                   mside_y(x,y,1,-1,4,-1,4);

                        }

                        else if ( vect_2o==2&&vect_1w==1 )            // фигура 4 клетки со смещением направо

                        { //1011

                                   mside_x(x,y,2,-2,3,-2,3);

                        }

                        else if ( vect_2w==2&&vect_1o==1 )            // фигура 4 клетки со смещением налево

                        {

                                   mside_x(x,y,3,-3,2,-3,2);

                        }

                        else if ( vect_2n==2&&vect_1s==1 ) // фигура 4 клетки со смещением вверх

                        {

                                   mside_y(x,y,3,-3,2,2,-3);

                        }

                        else if ( vect_2s==2&&vect_1n==1 ) // фигура 4 клетки со смещением вниз

                        {

                                   mside_y(x,y,2,-2,3,-2,3);

                        }

                        else if ( vect_2w==2&&vector_free2_o==1&&vect_14_w==0 )      // фигура 3 клетки  на оду сторону

                        {

                                   mside_x(x,y,3,-3,1,-3,1);

                        }

                        else if ( vect_2o==2&&vector_free2_w==1&&vect_14_o==0 )       // фигура 3 клетки  на оду сторону

                        {

                                   mside_x(x,y,1,-1,3,-1,3);

                        }

                        else if ( vect_2n==2&&vector_free2_s==1&&vect_14_n==0 )        // фигура 3 клетки  на оду сторону

                        {

                                   mside_y(x,y,3,-3,1,1,-3);

                        }

                        else if ( vect_2s==2&&vector_free2_n==1&&vect_14_s==0 )         // фигура 3 клетки  на оду сторону

                        {

                                   mside_y(x,y,1,-1,3,-1,3);

                        }

                        else if ( vect_1w==1&&vect_1o==1&&vector_free3_w==1&&vector_free3_o==1 ) // фигура 3 клетки по 1 на две стороны

                        {  //101

                                   mside_x(x,y,2,-2,2,-2,2);

                        }

                        else if ( vect_1n==1&&vect_1s==1&&vector_free3_n==1&&vector_free3_s==1 ) // фигура 3 клетки по 1 на две стороны

                        {  //101

                                   mside_y(x,y,2,-2,2,-2,2);

                        }

                        else if ( vect_1w==1&&vector_free2_o==1&&vector_free3_w==1 ) // фигура 2 клетки

                        {

                                   mside_x(x,y,2,-2,1,-2,1);

                        }

                        else if ( vect_1o==1&&vector_free2_w==1&&vector_free3_o==1 ) // фигура 2 клетки

                        {

                                   mside_x(x,y,1,-1,2,-1,2);

                        }

                        else if ( vect_1n==1&&vector_free2_s==1&&vector_free3_n==1 ) // фигура 2 клетки

                        {

                                   mside_y(x,y,2,-2,1,1,-2);

                        }

                        else if ( vect_1s==1&&vector_free2_n==1&&vector_free3_s==1 ) // фигура 2 клетки

                        {

                                   mside_y(x,y,1,-1,2,-1,2);

                        }

            }

}

void __fastcall TForm1::IManMouseMove(TObject *Sender, TShiftState Shift,

              int X, int Y)

{

            if (PNowYou->Visible&&(count_sh-cover))

            {

                        IMan->Picture->Assign(BitMapl);

                        if (X<=224)

                                   shift_X=0;

                        if (Y<=224)

                                   shift_Y=0;

                        switch(vector)

                        {

                                   case 0:

                                               shift_Y=0;

                                               switch(fign[cover])

                                               {

                                                           case 1:

                                                                       if (X>224)

                                                                                  shift_X=-3;

                                                                       else if (X>199)

                                                                                  shift_X=-2;

                                                                       else if (X>174)

                                                                                  shift_X=-1;

                                                           break;

                                                           case 2:

                                                                       if (X>224)

                                                                                  shift_X=-2;

                                                                       else if (X>199)

                                                                                  shift_X=-1;

                                                           break;

                                                           case 3:

                                                                       if (X>224)

                                                                                  shift_X=-1;

                                                           break;

                                                           case 4:

                                                                                  shift_X=0;

                                                           break;

                                               }

                                   break;

                                   case 1:

                                               shift_X=0;

                                               switch(fign[cover])

                                               {

                                                           case 1:

                                                                       if (Y>224)

                                                                                  shift_Y=-3;

                                                                       else if (Y>199)

                                                                                  shift_Y=-2;

                                                                       else if (Y>174)

                                                                                  shift_Y=-1;

                                                           break;

                                                           case 2:

                                                                       if (Y>224)

                                                                                  shift_Y=-2;

                                                                       else if (Y>199)

                                                                                  shift_Y=-1;

                                                           break;

                                                           case 3:

                                                                       if (Y>224)

                                                                                  shift_Y=-1;

                                                           break;

                                                           case 4:

                                                                                  shift_Y=0;

                                                           break;

                                               }

                                   break;

                        }

                        switch(vector)

                        {

                                   case 0:

                                               switch(fign[cover])

                                               {

                                                           case 1:

                                                                       mouse_down_right_x(X,Y,174,100,150);

                                                           break;

                                                           case 2:

                                                                       mouse_down_right_x(X,Y,199,75,175);

                                                           break;

                                                           case 3:

                                                                       mouse_down_right_x(X,Y,224,50,200);

                                                           break;

                                                           case 4:

                                                                       if (Windows1->Checked)

                                                                      {

                                                                                  IMan->Canvas->Draw(X/25*25,Y/25*25,BitMapw);

                                                                       }

                                                                       else

                                                                       {

                                                                                  IMan->Picture->Assign(BitMapl);

                                                                                  choice_coclour();

                                                                                  IMan->Canvas->Rectangle(0+X/25*25,0+Y/25*25,X/25*25+25,Y/25*25+25 );

                                                                       }

                                                           break;

                                               }

                                   break;

                                   case 1:

                                               switch(fign[cover])

                                               {

                                                           case 1:

                                                                       mouse_down_right_y(X,Y,174,100,150);

                                                           break;

                                                           case 2:

                                                                       mouse_down_right_y(X,Y,199,75,175);

                                                           break;

                                                           case 3:

                                                                       mouse_down_right_y(X,Y,224,50,200);

                                                           break;

                                                           case 4:

                                                                       if (Windows1->Checked)

                                                                       {

                                                                                  IMan->Canvas->Draw(X/25*25,Y/25*25,BitMapw);

                                                                       }

                                                                       else

                                                                       {

                                                                                  IMan->Picture->Assign(BitMapl);

                                                                                  choice_coclour();

                                                                                  IMan->Canvas->Rectangle(0+X/25*25,0+Y/25*25,X/25*25+25,Y/25*25+25 );

                                                                       }

                                                           break;

                                               }

                                   break;

                        }

            }

}

//---------------------------------------------------------------------------

void __fastcall TForm1::ICompMouseDown(TObject *Sender,

              TMouseButton Button, TShiftState Shift, int X, int Y)

{

            if (!TimerMachine->Enabled&&!ButtonChoiceScheme->Visible&&

                        !ButtonOwnScheme->Visible&&!PIThink->Visible&&!PNowYou->Visible&&

                        !PBegin->Visible&&!TimerAroundBrok->Enabled&&!BHideMap->Visible&&

                        !TimerTrassa->Enabled&&!TimerGo->Enabled&&!PWin->Visible&&

                        !TimerFlash->Enabled&&!TimerStart->Enabled&&!TimerRestart->Enabled)

            {

                        int sum_brok=0;

                        left_right=1;

                        LastShoot1->Enabled=false;

                        switch (comp.show_bit(X/25,Y/25))

                        {

                                   case 0:

                                               result=0;

                                               right_x=X/25;

                                               right_y=Y/25;

                                               comp.put_bit(right_x,right_y,3);

                                               side(X/25,Y/25,0);

                                               shoot_man++;

                                               covered_man++;

                                               need_man=0;

                                               if (English1->Checked)

                                               {

                                                           PManShoots->Caption="Shoots: "+IntToStr(shoot_man);

                                                           PManCovered->Caption="Covered: "+IntToStr(covered_man)+" % ";

                                               }

                                               else

                                               {

                                                           PManShoots->Caption="Выстрелы: "+IntToStr(shoot_man);

                                                           PManCovered->Caption="Накрыто: "+IntToStr(covered_man)+" % ";

                                               }

                                               TimerAroundBrok->Enabled=true;

                                               Kind1->Enabled=false;

                                   break;

                                   case 1:

                                               LastShoot1->Enabled=true;

                                               result=1;

                                               right_x=X/25;

                                               right_y=Y/25;

                                               comp.put_bit(right_x,right_y,2);

                                               side(X/25,Y/25,1);

                                               review(X/25,Y/25);

                                               shoot_man++;

                                               covered_man=0;

                                               for (int i=0;i<10;i++)

                                               {

                                                           for (int j=0;j<10;j++)

                                                           {

                                                                       if (comp.show_bit(i,j)==2)

                                                                       {

                                                                                  covered_man++;

                                                                                  sum_brok++;

                                                                       }

                                                                       if (comp.show_bit(i,j)==3)

                                                                       {

                                                                                  covered_man++;

                                                                       }

                                                           }

                                               }

                                               need_man=1;

                                               if (English1->Checked)

                                               {

                                                           PManShoots->Caption="Shoots: "+IntToStr(shoot_man);

                                                           PManCovered->Caption="Covered: "+IntToStr(covered_man)+" % ";

                                               }

                                               else

                                               {

                                                           PManShoots->Caption="Выстрелы: "+IntToStr(shoot_man);

                                                           PManCovered->Caption="Накрыто: "+IntToStr(covered_man)+" % ";

                                               }

//-----------------------------------------------------------------------------

void __fastcall TForm1::TimerStartTimer(TObject *Sender)

{

            static int change_images=0;

            change_images++;

            if (change_images==1)           //?

            {

                        IMan->Height=0;

                        IMan->Width=0;

                        IComp->Width=0;

                        IComp->Height=0;

                        IMan->Left=165;

                        IMan->Top=135;

                        IComp->Left=525;

                        IComp->Top=135;

                        IMan->Visible=true;

                        IComp->Visible=true;

                        Windows1->Checked=false;                         //

                        School1->Checked=true;                           //

                        Battle1->Checked=false;                          //

                        IRadarMan->Picture->Assign(IRadarSch->Picture);  //

                        IRadarComp->Picture->Assign(IRadarSch->Picture); //

                        BitMaprc->Assign(ICloseSch->Picture);            //

                        BitMaprz->Assign(IZeroSch->Picture);             //

                        BitMaprs->Assign(IShipSch->Picture);             //

                        BitMapm->Assign(IMS10->Picture);                 //

                        BitMapb->Assign(IBS10->Picture);                 //

                        BitMap->Assign(ISchool->Picture);                //

                        BitMapl->Assign(ISchool->Picture);               //

                        IMan->Picture->Assign(BitMapl);                  //

                        IComp->Picture->Assign(BitMap);                  //

            }

            else if (change_images<7)

            {

                        field_restart(1);

            }

            else

            {

                        TimerStart->Enabled=false;

                        English1->Checked=false;         //

                        Russian1->Checked=true;

                Level1->Caption="Уровень";

                Heavily1->Caption="Тяжело";

                Average1->Caption="Средне";

                Easily1->Caption="Легко";

                        Form1->Caption="Морской Бой";

                        NewGame1->Caption="Новая Игра";

                        Sound1->Caption="Звук";

                        LastShoot1->Caption="Посл. Удар";

                        Game->Caption="Игра";

                        Example1->Caption="Пример";

                        Help->Caption="Помощь";

                        Help1->Caption="Справка";

                        About1->Caption="О Программе";

                        ShowMap1->Caption="Карта";

                        OwnMap1->Caption="Своя Карта";

                        Hide1->Caption="Скрыть";

                        Show1->Caption="Показать";

                        Language1->Caption="Язык";

                        English1->Caption="Английский";

                        Russian1->Caption="Русский";

                        Radar1->Caption="Радар";

                        Sensitivity31->Caption="Чувствительность 3";

                        Sensitivity21->Caption="Чувствительность 2";

                        Sensitivity11->Caption="Чувствительность 1";

                        RadarOFF1->Caption="Радар Выкл.";

                        Kind1->Caption="Вид";

                        Battle1->Caption="Сундук";

                        School1->Caption="Школа";

                        Windows1->Caption="Wокнаs";

                        Exit1->Caption="Выход";

                        RadioGroup1->Caption=" Выбор  Схемы ";

                        Label3->Caption="1 Труба";

                        Label4->Caption="2 Трубы";

                        Label5->Caption="3 Трубы";

                        Label6->Caption="4 Трубы";

                        RadioGroup1->Items->Delete(0);

                        RadioGroup1->Items->Add("Основная");

                        RadioGroup1->Items->Delete(0);

                        RadioGroup1->Items->Add("Большие");

                        RadioGroup1->Items->Delete(0);

                        RadioGroup1->Items->Add("Малые");

                        RadioGroup1->Items->Delete(0);

                        RadioGroup1->Items->Add("Своя");

                        PWont->Caption="Ещё Одну Игру?";

                        BYes->Caption="ДА";

                        BNo->Caption="НЕТ";

                        PBegin->Caption="Кто Начинает Первым?";

                        BNemo->Caption="Нахимов";

                        BMachine->Caption="Железо";

                        BDelLastShip->Caption="Убрать Последний";

                        PIThink->Caption="Я Думаю";

                        PNowYou->Caption="Теперь Вы";

                        PMyShoot->Caption="Мой Ход";   //

                        PYourShoot->Caption="Ваш ход";

                        PManShoots->Caption="Выстрелы";

                        PManCovered->Caption="Накрыто";

                        PCompShoots->Caption="Выстрелы";

                        PCompCovered->Caption="Накрыто";

            }

}

//---------------------------------------------------------------------------

void __fastcall TForm1::NewGame1Click(TObject *Sender)

{

            if (!TimerRestart->Enabled&&!TimerStart->Enabled)

            {

                        TimerMachine->Enabled=false;

                        TimerOwnScheme->Enabled=false;

                        TimerAroundBrok->Enabled=false;

                        TimerThinkComp->Enabled=false;

                        TimerTrassa->Enabled=false;

                        TimerGo->Enabled=false;

                        TimerRestart->Enabled=true;

            }

}

//---------------------------------------------------------------------------

void __fastcall TForm1::TimerRestartTimer(TObject *Sender)

{

            static int change_images=0;

            if (change_images==1)

            {

                        if (Sound1->Checked)

                        {

                                   PlaySound("sounrest.wav",0,SND_ASYNC);

                        }

                        count_think=0;

                        first=0;

                        repeat=0;

                        count_mach=0;

                        tired=0;

                        ms=0;

                        ship4=0;

                        ship3=0;

                        ship2=0;

                        ship1=0;

                        cover=0;

                        count=0;

                        count_sh=0;

                        vector=1;

                        shoot_man=0;

                        shoot_comp=0;

                        covered_man=0;

                        covered_comp=0;

                        side_x_y=0;

                        need=0;

                        need_man=0;

                        need_x=-1;

                        tired_x=-1;

                        for (int i=0;i<16;i++)

                        {

                                   fign[i]=0;

                                   array_choice[i]=0;

                        }

                        for (int i=0;i<30;i++)

                                   arr_radar[i]=-1;

                        for (int i=0;i<4;i++)

                                   last_ship[i]=0;

                        man.setup(0);

                        comp.setup(0);

                        if (Battle1->Checked)

                        {

                                   IMan->Picture->Assign(BitMaplr);

                                   IComp->Picture->Assign(BitMaprr);

                                   BitMapl->Assign(IMan->Picture);

                                   BitMap->Assign(IComp->Picture);

                        }

                        else if (Windows1->Checked)

                        {

                                   IMan->Picture->Assign(IWindows->Picture);

                                   IComp->Picture->Assign(IWindows->Picture);

                                   BitMapl->Assign(IWindows->Picture);

                                   BitMap->Assign(IWindows->Picture);

                        }

                        else

                        {

                                   IMan->Picture->Assign(ISchool->Picture);

                                   IComp->Picture->Assign(ISchool->Picture);

                                   BitMapl->Assign(ISchool->Picture);

                                   BitMap->Assign(ISchool->Picture);

                        }

                        BHideMap->Visible=false;

                        BHideExample->Visible=false;

                        Language1->Enabled=true;

                        OwnMap1->Enabled=false;

                        Kind1->Enabled=true;

                        Hide1->Enabled=true;

                        Show1->Enabled=false;

                        Image1->Visible=false;

                        Image29->Visible=false;

                        Image2->Visible=false;

                        Image30->Visible=false;

                        Image3->Visible=false;

                        Image31->Visible=false;

                        Image4->Visible=false;

                        Image32->Visible=false;

                        Image5->Visible=false;

                        Image33->Visible=false;

                        Image6->Visible=false;

                        Image34->Visible=false;

                        Image7->Visible=false;

                        Image35->Visible=false;

                        Image8->Visible=false;

                        Image36->Visible=false;

                        Image9->Visible=false;

                        Image37->Visible=false;

                        Image10->Visible=false;

                        Image38->Visible=false;

                        Image11->Visible=false;

                        Image39->Visible=false;

                        Image12->Visible=false;

                        Image40->Visible=false;

                        Image13->Visible=false;

                        Image41->Visible=false;

                        Image14->Visible=false;

                        Image42->Visible=false;

                        Image15->Visible=false;

                        Image43->Visible=false;

                        Image16->Visible=false;

                        Image44->Visible=false;

                        Image17->Visible=false;

                        Image45->Visible=false;

                        Image18->Visible=false;

                        Image46->Visible=false;

                        Image19->Visible=false;

                        Image47->Visible=false;

                        Image20->Visible=false;

                        Image48->Visible=false;

                        Image21->Visible=false;

                        Image49->Visible=false;

                        Image22->Visible=false;

                        Image50->Visible=false;

                        Image23->Visible=false;

                        Image51->Visible=false;

                        Image24->Visible=false;

                        Image52->Visible=false;

                        Image25->Visible=false;

                        Image53->Visible=false;

                        Image26->Visible=false;

                        Image54->Visible=false;

                        Image27->Visible=false;

                        Image55->Visible=false;

                        Image28->Visible=false;

                        Image56->Visible=false;

                        BOkFull->Visible=false;

                        BevelL->Visible=false;

                        BevelR->Visible=false;

                        BDelLastShip->Visible=false;

                        PWont->Visible=false;

                        BYes->Visible=false;

                        BNo->Visible=false;

                        Radar1->Enabled=true;           //false;

                Level1->Enabled=true;

                        RadarOFF1->Checked=false;

                        Sensitivity31->Checked=true;

                        Sensitivity21->Checked=false;

                        Sensitivity11->Checked=false;

                        radar_zero(1);

                        radar_sensitivity=3;

                        Example1->Enabled=true;

                        ShowMap1->Enabled=false;

                        Kind1->Enabled=false;

                        if (English1->Checked)

                        {

                                   PCompCovered->Caption="Covered";

                                   PManCovered->Caption="Covered";

                                   PCompShoots->Caption="Shoots";

                                   PManShoots->Caption="Shoots";

                        }

                        else

                        {

                                   PCompCovered->Caption="Накрыто";

                                   PManCovered->Caption="Накрыто";

                                   PCompShoots->Caption="Выстелы";

                                   PManShoots->Caption="Выстелы";

                        }

                        PIThink->Hide();

                        PNowYou->Hide();

                        PMyShoot->Hide();

                        PYourShoot->Hide();

                        PCompCovered->Visible=false;

                        PCompShoots->Visible=false;

                        BCompResults->Visible=false;

                        PManCovered->Visible=false;

                        PManShoots->Visible=false;

                        BManResults->Visible=false;

                        PIThink->Visible=false;

                        PNowYou->Visible=false;

                        PMyShoot->Visible=false;

                        PYourShoot->Visible=false;

                        PBegin->Visible=false;

                        BNemo->Visible=false;

                        BMachine->Visible=false;

                        PWin->Visible=false;

                        RadioGroup1->ItemIndex=0;

                        UpDown1->Position=0;

                        UpDown2->Position=0;

                        UpDown3->Position=0;

                        UpDown4->Position=0;

                        RadioGroup1->Visible=false;

                        UpDown1->Visible=false;

                        UpDown2->Visible=false;

                        UpDown3->Visible=false;

                        UpDown4->Visible=false;

                        ButtonChoiceScheme->Visible=false;

                        ButtonOwnScheme->Visible=false;

                        Label1->Visible=false;

                        Label2->Visible=false;

                        Label3->Visible=false;

                        Label4->Visible=false;

                        Label5->Visible=false;

                        Label6->Visible=false;

                        Label7->Visible=false;

                        Label8->Visible=false;

                        Bevel1->Visible=false;

                        Bevel2->Visible=false;

                        Bevel3->Visible=false;

                        Bevel4->Visible=false;

                        PVeryMany->Visible=false;

                        IVeryMany2->Visible=false;

                        IVeryMany->Visible=false;

                        con_man=0;

            }

            else if (change_images>1&&change_images<7)

            {

                        field_restart(0);

            }

            else if (change_images>6&&change_images<12)

            {

                        field_restart(1);

            }

            else if (change_images>11)

            {

                        change_images=0;

                        TimerRestart->Enabled=false;

                        RadioGroup1->Visible=true;

                        ButtonChoiceScheme->Visible=true;

                        Kind1->Enabled=true;

                        TimerFlash->Enabled=true;

            }

            change_images++;

}