資源描述:
《VS2008——VB掃雷游戲》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、VS2008——VB掃雷游戲掃雷游戲是一個(gè)經(jīng)典游戲,無數(shù)人用各種編程語言寫過它?,F(xiàn)在用VS2008——VB編寫,效果很好。游戲主要用Label控件寫成,對(duì)它的一些屬性都用編程的方法實(shí)現(xiàn),如:字體的設(shè)置、邊框線(樣式)、背景顏色的設(shè)置、定位、圖像的輸出等。本游戲共用了84個(gè)Label控件。圖1、掃雷游戲程序運(yùn)行中圖2、窗體設(shè)計(jì)頁面圖3、打開非雷方塊(片區(qū)域)圖4、游戲勝利結(jié)束圖5、勝利信息框下面是程序中用到的一些位圖圖源(位圖綁定要以自己存放位置為準(zhǔn)):1、笑臉2、苦臉3、面圖4、地雷5、底片附程序全部源碼:PublicStructureGAMEDimopen_stateAsIntegerDi
2、mm_stateAsIntegerDimm_numbersAsIntegerEndStructurePublicClassForm1PublicSWIDTHAsInteger=285PublicSHEIGHTAsInteger=410PublicGRECTAsInteger=30DimPos(0To8)AsIntegerDimGame(0To8,0To8)AsGAMEDimg_onAsInteger=0DimrAsInteger,cAsInteger,open_mAsIntegerPrivateSubsetmine()DimiAsInteger,trAsInteger,tcAsInteger
3、,rtAsIntegerRandomize()Fori=1To10rt=1DoWhilert=1tr=Int(Rnd()*8)+1tc=Int(Rnd()*8)+1IfGame(tr,tc).m_state=0ThenGame(tr,tc).m_state=1rt=0EndIfLoopNextEndSubPrivateSubgetminenumbers()DimiAsInteger,jAsInteger,numbersAsIntegerFori=0To8Forj=0To8numbers=0IfGame(i,j).m_state=0ThenIfi>0ThenIfGame(i-1,j).m_st
4、ate=1Thennumbers=numbers+1EndIfIfj>0ThenIfGame(i-1,j-1).m_state=1Thennumbers=numbers+1EndIfEndIfIfj<8ThenIfGame(i-1,j+1).m_state=1Thennumbers=numbers+1EndIfEndIfEndIfIfi<8ThenIfGame(i+1,j).m_state=1Thennumbers=numbers+1EndIfIfj>0ThenIfGame(i+1,j-1).m_state=1Thennumbers=numbers+1EndIfEndIfIfj<8ThenI
5、fGame(i+1,j+1).m_state=1Thennumbers=numbers+1EndIfEndIfEndIfIfj>0ThenIfGame(i,j-1).m_state=1Thennumbers=numbers+1EndIfEndIfIfj<8ThenIfGame(i,j+1).m_state=1Thennumbers=numbers+1EndIfEndIfEndIfGame(i,j).m_numbers=numbersNextNextEndSubPrivateFunctionretselect(ByValmrAsInteger,ByValmcAsInteger)DimrtAsI
6、nteger=0IfGame(mr,mc).open_state=1OrGame(mr,mc).m_state=1Thenrt=1EndIfIfGame(mr,mc).open_state=0ThenSelectCasemrCaseIs=0SelectCasemcCaseIs=0open_mylabel(Label1,mr,mc)CaseIs=1open_mylabel(Label2,mr,mc)CaseIs=2open_mylabel(Label3,mr,mc)CaseIs=3open_mylabel(Label4,mr,mc)CaseIs=4open_mylabel(Label5,mr,
7、mc)CaseIs=5open_mylabel(Label6,mr,mc)CaseIs=6open_mylabel(Label7,mr,mc)CaseIs=7open_mylabel(Label8,mr,mc)CaseIs=8open_mylabel(Label9,mr,mc)EndSelectCaseIs=1SelectCasemcCaseIs=0open_mylabel(Label10,mr,mc)Cas