ВУЗ: Не указан

Категория: Не указан

Дисциплина: Не указана

Добавлен: 30.03.2025

Просмотров: 195

Скачиваний: 1

ВНИМАНИЕ! Если данный файл нарушает Ваши авторские права, то обязательно сообщите нам.

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++;

}

}

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

void __fastcall TForm1::TimerThinkCompTimer(TObject *Sender)

{

count_think++;

IComp->Picture->Assign(BitMap);

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

{

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

{

paint_array(x,y);

}

}

comp.next_ship(RadioGroup1->ItemIndex,1);

if (count_think==30) // 50 75

{

if (!Easily1->Checked)

{

comp.next_ship(RadioGroup1->ItemIndex,radar_sensitivity);

}

else

{

comp.next_ship(RadioGroup1->ItemIndex,1);

}

count_think=0;

PIThink->Visible=false;

TimerThinkComp->Enabled=false;

PNowYou->Visible=true;

cover=0;

IComp->Picture->Assign(BitMap);

Kind1->Enabled=true;

}

}

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

void __fastcall TForm1::FormCreate(TObject *Sender)

{

BitMap=new Graphics::TBitmap;

BitMap->Width=250;

BitMap->Height=250;

BitMap->Assign(IComp->Picture);

BitMapl=new Graphics::TBitmap;

BitMapl->Width=250;

BitMapl->Height=250;

BitMapl->Assign(IMan->Picture);

BitMaplr=new Graphics::TBitmap;

BitMaplr->Width=250;

BitMaplr->Height=250;

BitMaplr->Assign(IMan->Picture);

BitMaprr=new Graphics::TBitmap;

BitMaprr->Width=250;

BitMaprr->Height=250;

BitMaprr->Assign(IComp->Picture);

BitMapm=new Graphics::TBitmap;

BitMapm->Width=25;

BitMapm->Height=25;

BitMapm->Assign(Milk->Picture);

BitMapb=new Graphics::TBitmap;

BitMapb->Width=25;

BitMapb->Height=25;

BitMaprs=new Graphics::TBitmap;

BitMaprs->Width=8;

BitMaprs->Height=8;

BitMaprs->Assign(IShip->Picture);

BitMaprz=new Graphics::TBitmap;

BitMaprz->Width=8;

BitMaprz->Height=8;

BitMaprz->Assign(IZero->Picture);

BitMaprc=new Graphics::TBitmap;

BitMaprc->Width=8;

BitMaprc->Height=8;

BitMaprc->Assign(IClose->Picture);

BitMaprf=new Graphics::TBitmap;

BitMaprf->Width=120;

BitMaprf->Height=120;

BitMapw=new Graphics::TBitmap;

BitMapw->Width=25;

BitMapw->Height=25;

BitMapw->Assign(IFold->Picture);


BitMapLm=new Graphics::TBitmap;

BitMapLm->Width=25;

BitMapLm->Height=25;

BitMapLc=new Graphics::TBitmap;

BitMapLc->Width=25;

BitMapLc->Height=25;

IRadarMan->Picture->Assign(IRadarBattle->Picture);

IRadarComp->Picture->Assign(IRadarBattle->Picture);

Screen->Cursors[crMyCursor]=LoadCursor(HInstance,"TARGET");

Screen->Cursors[crMyCursorh]=LoadCursor(HInstance,"HOOK");

IMan->Cursor=(TCursor)crMyCursorh;

IComp->Cursor=(TCursor)crMyCursor;

srand(time(0));

}

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

void __fastcall TForm1::FormDestroy(TObject *Sender)

{

BitMap->Free();

BitMapl->Free();

BitMaplr->Free();

BitMaprr->Free();

BitMapm->Free();

BitMapb->Free();

BitMaprs->Free();

BitMaprz->Free();

BitMaprc->Free();

BitMapw->Free();

BitMapLm->Free();

BitMapLc->Free();

Application->HelpCommand(HELP_QUIT,0);

}

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

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

{

if (comp.show_bit(x,y)==1||comp.show_bit(x,y)==2) //comp

{

if (School1->Checked)

{

IComp->Canvas->Pen->Width=3;

IComp->Canvas->Pen->Color=clNavy;

IComp->Canvas->Brush->Color=clGray;

IComp->Canvas->Rectangle(x*25+1,y*25+1,x*25+25-1,y*25+25-1);

}

else if (Windows1->Checked)

IComp->Canvas->Draw(x*25,y*25,BitMapw);

else

{

IComp->Canvas->Brush->Color = clTeal;

IComp->Canvas->Pen->Color = clTeal;

IComp->Canvas->Rectangle(x*25,y*25,x*25+25,y*25+25 );

}

}

}

void __fastcall TForm1::Exit1Click(TObject *Sender)

{

Close();

}

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

void __fastcall TForm1::IManMouseDown(TObject *Sender,

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

{

if (PNowYou->Visible&&(count_sh-cover)) //||!PMyShoot->Visible)

{

IMan->Picture->Assign(BitMapl);

if (Button==mbRight)

switch(vector)

{

case 0:

vector=1;

shift_X=0;

switch(fign[cover])

{

case 1:

if (X>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;

}

{

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);

}

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(X/25*25,Y/25*25,X/25*25+25,Y/25*25+25 );

}

break;

}

break;

}

}

else if (Button == mbLeft)


{

if (!man.control(X/25+shift_X, Y/25+shift_Y, vector, fign[cover],1)) // not 2,1 !!!

{

switch(vector)

{

case 0:

switch(fign[cover])

{

case 1:

mouse_down_left_0(X,Y,100,1);

break;

case 2:

mouse_down_left_0(X,Y,75,2);

break;

case 3:

mouse_down_left_0(X,Y,50,3);

break;

case 4:

mouse_down_left_0(X,Y,25,4);

break;

}

break;

case 1:

switch(fign[cover])

{

case 1:

mouse_down_left_1(X,Y,100,1);

break;

case 2:

mouse_down_left_1(X,Y,75,2);

break;

case 3:

mouse_down_left_1(X,Y,50,3);

break;

case 4:

mouse_down_left_1(X,Y,25,4);

break;

}

break;

}

if (cover==count_sh-1)

{

BitMapl->Assign(IMan->Picture); // if not shape!!!

BOkFull->Visible=true;

last_ship[0]=X/25+shift_X;

last_ship[1]=Y/25+shift_Y;

last_ship[2]=vector;

last_ship[3]=5-fign[cover];

BDelLastShip->Visible=true;

cover++;

}

}

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

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)+" % ";

}

switch(count-sum_brok)

{

case 0:

Image56->Picture->Assign(IRed->Picture);

case 1:

Image55->Picture->Assign(IRed->Picture);

case 2:

Image54->Picture->Assign(IRed->Picture);

case 3:

Image53->Picture->Assign(IRed->Picture);


case 4:

Image52->Picture->Assign(IRed->Picture);

case 5:

Image51->Picture->Assign(IRed->Picture);

case 6:

Image50->Picture->Assign(IRed->Picture);

case 7:

Image49->Picture->Assign(IRed->Picture);

case 8:

Image48->Picture->Assign(IRed->Picture);

case 9:

Image47->Picture->Assign(IRed->Picture);

case 10:

Image46->Picture->Assign(IRed->Picture);

case 11:

Image45->Picture->Assign(IRed->Picture);

case 12:

Image44->Picture->Assign(IRed->Picture);

case 13:

Image43->Picture->Assign(IRed->Picture);

case 14:

Image42->Picture->Assign(IRed->Picture);

case 15:

Image41->Picture->Assign(IRed->Picture);

case 16:

Image40->Picture->Assign(IRed->Picture);

case 17:

Image39->Picture->Assign(IRed->Picture);

case 18:

Image38->Picture->Assign(IRed->Picture);

case 19:

Image37->Picture->Assign(IRed->Picture);

case 20:

Image36->Picture->Assign(IRed->Picture);

case 21:

Image35->Picture->Assign(IRed->Picture);

case 22:

Image34->Picture->Assign(IRed->Picture);

case 23:

Image33->Picture->Assign(IRed->Picture);

case 24:

Image32->Picture->Assign(IRed->Picture);

case 25:

Image31->Picture->Assign(IRed->Picture);

case 26:

Image30->Picture->Assign(IRed->Picture);

case 27:

Image29->Picture->Assign(IRed->Picture);

}

TimerAroundBrok->Enabled=true;

Kind1->Enabled=false;

break;

case 2:

case 3:

LastShoot1->Enabled=true;

}

}

}

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

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

{

IMan->Picture->Assign(BitMapl);

IMan->Canvas->Pen->Width=2;

IMan->Canvas->Pen->Mode=pmMergeNotPen;

IMan->Canvas->Ellipse(x-3,y-3,x+29,y+29);

IMan->Canvas->Pen->Width=1;

IMan->Canvas->Rectangle(x+12,y+12,x+14,y+14);

IMan->Canvas->Rectangle(x+12,y+6,x+14,y+9); //n

IMan->Canvas->Rectangle(x+12,y,x+14,y+4); //u

IMan->Canvas->Rectangle(x+12,y+16,x+14,y+19); //s

IMan->Canvas->Rectangle(x+12,y+21,x+14,y+25); //d

IMan->Canvas->Rectangle(x+6,y+12,x+9,y+14); //w

IMan->Canvas->Rectangle(x,y+12,x+4,y+14); //l

IMan->Canvas->Rectangle(x+16,y+12,x+19,y+14); //o

IMan->Canvas->Rectangle(x+21,y+12,x+25,y+14); //r

}

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

void __fastcall TForm1::TimerMachineTimer(TObject *Sender)

{

static int step_x;

static int step_y;

static int add_x_or_y;

int arr_tired[198]={0};

if (first==0&&tired_x<0)

{

first=1;

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

{

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

{

if (man.show_bit(i,j)==0||man.show_bit(i,j)==1)

{

arr_tired[tired*2]=i;

arr_tired[tired*2+1]=j;

tired++;

}

}

}

tired=(rand()%tired)*2;

step_x=arr_tired[tired];

step_y=arr_tired[tired+1];

tired=0;

PMyShoot->Visible=true;

PYourShoot->Visible=false;

marker_move(step_x*25,step_y*25);

}

else

{

if (tired_x<0)

{

count_mach++;

if (!(count_mach%2)&&!ms)

{

int step=rand()%100;

if (step<25)

{

if (step_x>0)

{

step_x--;

add_x_or_y=2;

}

else

{

step_x++;


add_x_or_y=1;

}

}

else if (step<50)

{

if (step_x<9)

{

step_x++;

add_x_or_y=1;

}

else

{

step_x--;

add_x_or_y=2;

}

}

else if (step<75)

{

if (step_y>0)

{

step_y--;

add_x_or_y=4;

}

else

{

step_y++;

add_x_or_y=3;

}

}

else

{

if (step_y<9)

{

step_y++;

add_x_or_y=3;

}

else

{

step_y--;

add_x_or_y=4;

}

}

}

if (count_mach%2)

{

marker_move(step_x*25,step_y*25);

}

else

{

count_mach--;

ms++;

if (ms>3)

{

count_mach++;

ms=0;

}

else

{

switch(add_x_or_y)

{

case 1:

marker_move(step_x*25-(24-6*ms),step_y*25);

break;

case 2:

marker_move(step_x*25+(24-6*ms),step_y*25);

break;

case 3:

marker_move(step_x*25,step_y*25-(24-6*ms));

break;

case 4:

marker_move(step_x*25,step_y*25+(24-6*ms));

break;

}

}

}

}

else

{

tired=0;

count_mach=19;

tired_x=-1;

step_x=need_x;

step_y=need_y;

PYourShoot->Visible=false;

PMyShoot->Visible=true;

}

if (count_mach==19) //20

{

left_right=0;

if (man.show_bit_deep(step_x,step_y)==1&&man.show_bit(step_x,step_y)!=1)

{

write_read_arr_tired(arr_tired);

}

else

{

switch (man.show_bit(step_x,step_y))

{

case 0:

tired=0;

result=0;

man.put_bit(step_x,step_y,3);

IMan->Picture->Assign(BitMapl);

mside(step_x,step_y,0);

first=0;

count_mach=0;

brok_milk(step_x,step_y);

if (radar_sensitivity&&Heavily1->Checked)

{

switch (radar_sensitivity)

{

case 3:

write_deep(step_x,step_y,3);

break;

case 2:

write_deep(step_x,step_y,2);

break;

case 1:

write_deep(step_x,step_y,1);

break;

}

}

PMyShoot->Visible=false;

PYourShoot->Visible=true;

break;

case 1:

need=1;

tired=0;

result=1;

man.put_bit(step_x,step_y,2);

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

void __fastcall TForm1::BNemoClick(TObject *Sender)

{

begin_move();

PYourShoot->Visible=true;

}

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

void __fastcall TForm1::BMachineClick(TObject *Sender)

{

begin_move();

PMyShoot->Visible=true;

TimerMachine->Enabled=true;

}

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

void __fastcall TForm1::TimerAroundBrokTimer(TObject *Sender)

{

if (!repeat)

{

case 0:

switch(repeat)

{

case 0:

{

explotion(1);

}

if (School1->Checked)

BitMapb->Assign(IMS1->Picture);

else if (Windows1->Checked)

BitMapb->Assign(IRecy1->Picture);

else

BitMapb->Assign(Milk01->Picture);

break;

}

repeat++;

if (left_right==0)

{

IMan->Canvas->Draw(need_x*25,need_y*25,BitMapb); // */

last_x_show=need_x;

last_y_show=need_y;

}

else

IComp->Canvas->Draw(right_x*25,right_y*25,BitMapb); // */