?? mainform.cpp
字號:
if((POS[x][y]->opened)&&(POS[x][y]->state == "flag")&&(POS[x][y]->are_you_bomb == 0))
{
Draw(x,y,"not_bomb");
}
if (POS[x][y]->opened) return false;
if ((POS[x][y]->are_you_bomb!=1)&&(POS[x][y]->around_bomb>0))
{
Draw(x,y,IntToStr(POS[x][y]->around_bomb)+"-");
POS[x][y]->opened = true;
POS[x][y]->state = IntToStr(POS[x][y]->around_bomb)+"-";
}
if (POS[x][y]->are_you_bomb==1)
{
Timer1->Enabled = false;
for (int i=0;i<globa_width;i++)
for (int j=0;j<globa_height;j++)
{
if(POS[i][j]->are_you_bomb==1)
{
Draw(i,j,"bomb");
POS[i][j]->opened = true;
POS[i][j]->state = "bomb";
}
POS[i][j]->opened = true;
}
Draw(x,y,"bomb_bomb");
POS[x][y]->opened = true;
POS[x][y]->state = "bomb_bomb";
gameover = true;
return false;
}
if ((POS[x][y]->around_bomb==0)&&(x<=m-1)&&(y<=n-1)&&(x>=0)&&(y>=0))
{
Draw(x,y,"0-");
POS[x][y]->opened = true;
POS[x][y]->state = "0-";
if(y!=0)
Open(x,y-1);
if(y!=n-1)
Open(x,y+1);
if(x!=0)
Open(x-1,y);
if(x!=m-1)
Open(x+1,y);
if((x!=0)&&(y!=0))
Open(x-1,y-1);
if((x!=0)&&(y!=n-1))
Open(x-1,y+1);
if((x!=m-1)&&(y!=0))
Open(x+1,y-1);
if((x!=m-1)&&(y!=n-1))
Open(x+1,y+1);
}
return true;
}
//---------------------------------------------------------------------------
void __fastcall TCleanBomb::FormCreate(TObject *Sender)
{
Randomize();
init_interface(globa_width,globa_height,globa_bomb_num);
}
//---------------------------------------------------------------------------
void __fastcall TCleanBomb::FormPaint(TObject *Sender)
{
for (int i=0;i<globa_width;i++)
for (int j=0;j<globa_height;j++)
{
POS[i][j]->show();
}
}
//---------------------------------------------------------------------------
void TCleanBomb::left_right_click(int x,int y)
{
if(!POS[x][y]->opened) return;
int around_num=0;
try
{
if((x-1>=0)&&(y-1>=0))
{
if(POS[x-1][y-1]->state == "flag")
around_num++;
}
if(x-1>=0)
{
if(POS[x-1][y]->state == "flag")
around_num++;
}
if((x-1>=0)&&(y+1<=globa_height-1))
{
if(POS[x-1][y+1]->state == "flag")
around_num++;
}
if(y-1>=0)
{
if(POS[x][y-1]->state == "flag")
around_num++;
}
if(y+1<=globa_height-1)
{
if(POS[x][y+1]->state == "flag")
around_num++;
}
if((x+1<=globa_width-1)&&(y-1>=0))
{
if(POS[x+1][y-1]->state == "flag")
around_num++;
}
if(x+1<=globa_width-1)
{
if(POS[x+1][y]->state == "flag")
around_num++;
}
if((x+1<=globa_width-1)&&(y+1<=globa_height-1))
{
if(POS[x+1][y+1]->state == "flag")
around_num++;
}
if(around_num==POS[x][y]->around_bomb)
{
if((x-1>=0)&&(y-1>=0))
Open(x-1,y-1);
if(x-1>=0)
Open(x-1,y);
if((x-1>=0)&&(y+1<=globa_height-1))
Open(x-1,y+1);
if(y-1>=0)
Open(x,y-1);
if(y+1<=globa_height-1)
Open(x,y+1);
if((x+1<=globa_width-1)&&(y-1>=0))
Open(x+1,y-1);
if(x+1<=globa_width-1)
Open(x+1,y);
if((x+1<=globa_width-1)&&(y+1<=globa_height-1))
Open(x+1,y+1);
}
}
catch(...)
{
}
}
void TCleanBomb::f2(TMessage m)
{
//TODO: Add your source code here
if(m.WParam == 113)
N2Click(NULL);
}
void __fastcall TCleanBomb::N13Click(TObject *Sender)
{
AnsiString P[3],s[3],str;
TStringList * aList;
aList = read_score();
// 就OK了,現在aList->Strings[0]就是fjye,20,以此類推
for(int i=0;i<aList->Count;i++)
{
AnsiString temp = aList->Strings[i];
P[i] = temp.SubString(1,temp.Pos(",")-1);
s[i] = temp.SubString(temp.Pos(",")+1,temp.Length());
}
for(int i=aList->Count;i<3;i++)
{
P[i] = "無名氏";
s[i] = 999;
}
delete aList;
sort->Label13->Caption = P[0];
sort->Label14->Caption = s[0]+"秒";
sort->Label15->Caption = P[1];
sort->Label16->Caption = s[1]+"秒";
sort->Label17->Caption = P[2];
sort->Label18->Caption = s[2]+"秒";
sort->ShowModal();
}
//---------------------------------------------------------------------------
void TCleanBomb::bombnum_pic(int num)
{
/* //TODO: Add your source code here
int p1,p2,p3;
p1 = num/100;
p2 = (num-p1*100)/10;
p3 = num-p1*100-p2*10;
AnsiString state;
try
{
Bitmap1 = new Graphics::TBitmap();
state = "JPG"+IntToStr(p1);
Bitmap1->LoadFromResourceName((int)HInstance,state);
//Bitmap1->LoadFromResourceName((int)HInstance,POS[i][j]->state);
Canvas->Draw(0,4,Bitmap1);
p1 = Bitmap1->Width;
state = "JPG"+IntToStr(p2);
Bitmap1->LoadFromResourceName((int)HInstance,state);
//Bitmap1->LoadFromResourceName((int)HInstance,POS[i][j]->state);
Canvas->Draw(p1,4,Bitmap1);
p2 = Bitmap1->Width;
state = "JPG"+IntToStr(p3);
Bitmap1->LoadFromResourceName((int)HInstance,state);
//Bitmap1->LoadFromResourceName((int)HInstance,POS[i][j]->state);
Canvas->Draw(p2+p1,4,Bitmap1);
}
catch (...)
{
MessageBeep(0);
}
delete Bitmap1; */
Label1->Caption = num;
}
void TCleanBomb::time_pic(int time)
{
//TODO: Add your source code here
/* int s1,s2,s3;
s1 = time/100;
s2 = (time-s1*100)/10;
s3 = time-s1*100-s2*10;
AnsiString state;
try
{
Bitmap1 = new Graphics::TBitmap();
state = "JPG"+IntToStr(s3);
Bitmap1->LoadFromResourceName((int)HInstance,state);
//Bitmap1->LoadFromResourceName((int)HInstance,POS[i][j]->state);
Canvas->Draw(Width-Bitmap1->Width-5,4,Bitmap1);
s3 = Width-Bitmap1->Width;
state = "JPG"+IntToStr(s2);
Bitmap1->LoadFromResourceName((int)HInstance,state);
//Bitmap1->LoadFromResourceName((int)HInstance,POS[i][j]->state);
Canvas->Draw(s3-Bitmap1->Width-5,4,Bitmap1);
s2 = s3-Bitmap1->Width;
state = "JPG"+IntToStr(s1);
Bitmap1->LoadFromResourceName((int)HInstance,state);
//Bitmap1->LoadFromResourceName((int)HInstance,POS[i][j]->state);
Canvas->Draw(s2-Bitmap1->Width-5,4,Bitmap1);
}
catch (...)
{
MessageBeep(0);
}
delete Bitmap1; */
Label2->Caption = time;
Label2->Left = Panel1->Width-Label2->Width-10 ;
}
void __fastcall TCleanBomb::N9Click(TObject *Sender)
{
ShowMessage("按照Windows的掃雷游戲做的,不需要多說了吧");
}
//---------------------------------------------------------------------------
TStringList* TCleanBomb::read_score()
{
//TODO: Add your source code here
TStringList * aList = new TStringList();
try
{
regkey = new TRegistry();
regkey->RootKey=HKEY_LOCAL_MACHINE;//設置根鍵 //打開自動登錄所在的鍵
regkey->OpenKey("SOFTWARE\\fjye\\cleanbomb\\score",true);
aList->Delimiter = ';';
aList->DelimitedText = regkey->ReadString("score");;
delete regkey;
}
catch(...)
{
aList->DelimitedText = "";
}
return aList;
}
void TCleanBomb::write_score(AnsiString m)
{
//TODO: Add your source code here
regkey = new TRegistry();
regkey->RootKey=HKEY_LOCAL_MACHINE;//設置根鍵 //打開自動登錄所在的鍵
regkey->OpenKey("SOFTWARE\\fjye\\cleanbomb\\score",true);
regkey->WriteString("score",m);
delete regkey;
}
TStringList* TCleanBomb::read_last_config()
{
TStringList * aList = new TStringList();
regkey = new TRegistry();
regkey->RootKey=HKEY_LOCAL_MACHINE;//設置根鍵 //打開自動登錄所在的鍵
regkey->OpenKey("SOFTWARE\\fjye\\cleanbomb\\score",true);
aList->Delimiter = ',';
aList->DelimitedText = regkey->ReadString("last_config");
delete regkey;
return aList;
}
void TCleanBomb::write_last_config(AnsiString con)
{
regkey = new TRegistry();
regkey->RootKey=HKEY_LOCAL_MACHINE;//設置根鍵 //打開自動登錄所在的鍵
regkey->OpenKey("SOFTWARE\\fjye\\cleanbomb\\score",true);
regkey->WriteString("last_config",con);
delete regkey;
}
void __fastcall TCleanBomb::FormClose(TObject *Sender,
TCloseAction &Action)
{
write_last_config(IntToStr(globa_width)+","+IntToStr(globa_height)+","+IntToStr(globa_bomb_num));
}
//---------------------------------------------------------------------------
void TCleanBomb::check_log()
{
//TODO: Add your source code here
TStringList * aList;
aList = read_score();
if(aList->DelimitedText=="")
{
write_score("無名氏,999;無名氏,999;無名氏,999");
aList = read_score();
}
AnsiString temp;
if(N5->Checked)
{
temp = aList->Strings[0];
if(wastetime<StrToInt(temp.SubString(temp.Pos(",")+1,temp.Length())))
{
AnsiString name;
if (InputQuery("恭喜你,已經刷新本級別的紀錄", "請輸入你的大名: ", name))
{
}
else
{
name = "無名氏";
}
aList->Strings[0] = name+","+IntToStr(wastetime);
}
}
if(N6->Checked)
{
temp = aList->Strings[1];
if(wastetime<StrToInt(temp.SubString(temp.Pos(",")+1,temp.Length())))
{
AnsiString name;
if (InputQuery("恭喜你,已經刷新本級別的紀錄", "請輸入你的大名: ", name))
{
}
else
{
name = "無名氏";
}
aList->Strings[1] = name+","+IntToStr(wastetime);
}
}
if(N7->Checked)
{
temp = aList->Strings[2];
if(wastetime<StrToInt(temp.SubString(temp.Pos(",")+1,temp.Length())))
{
AnsiString name;
if (InputQuery("恭喜你,已經刷新本級別的紀錄", "請輸入你的大名: ", name))
{
}
else
{
name = "無名氏";
}
aList->Strings[2] = name+","+IntToStr(wastetime);
}
}
write_score(aList->DelimitedText);
delete aList;
}
void __fastcall TCleanBomb::FormResize(TObject *Sender)
{
Label2->Left = Panel1->Width-Label2->Width-10 ;
SpeedButton1->Left = (Panel1->Width-SpeedButton1->Width)/2;
}
//---------------------------------------------------------------------------
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -