資源描述:
《C++編寫地“掃雷”源程序》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫(kù)。
1、實(shí)用文檔//headerfile#include#include#include#include#include//defines#defineKEY_UP0xE048#defineKEY_DOWN0xE050#defineKEY_LEFT0xE04B#defineKEY_RIGHT0xE04D#defineKEY_ESC0x001B#defineKEY_1'1'#defineKEY_2'2'#defineKEY_3'3'#defineGAME_MAX_WIDTH100
2、#defineGAME_MAX_HEIGHT100//StringsResource#defineSTR_GAMETITLE"ArrowKey:MoveCursorKey1:OpenKey2:MarkKey3:OpenNeighbors"#defineSTR_GAMEWIN"Congratulations!YouWin!Thankyouforplaying!"#defineSTR_GAMEOVER"GameOver,thankyouforplaying!"#defineSTR_GAMEEND"Presentedbyyzfy.PressESCtoexi
3、t"http://-------------------------------------------------------------//BaseclassclassCConsoleWnd{public:文案大全實(shí)用文檔staticintTextOut(constchar*);staticintGotoXY(int,int);staticintCharOut(int,int,constint);staticintTextOut(int,int,constchar*);staticintGetKey();public:};//{{//classCConsoleW
4、nd////intCConsoleWnd::GetKey()//WaitforstandardinputandreturntheKeyCode//intCConsoleWnd::GetKey(){intnkey=getch(),nk=0;if(nkey>=128
5、
6、nkey==0)nk=getch();returnnk>0?nkey*256+nk:nkey;}////intCConsoleWnd::GotoXY(intx,inty)//Movecursorto(x,y)//OnlyConsoleApplication//intCConsoleWnd::Goto
7、XY(intx,inty){COORDcd;cd.X=x;cd.Y=y;returnSetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),cd);文案大全實(shí)用文檔}////intCConsoleWnd::TextOut(constchar*pstr)//Outputastringatcurrentposition//intCConsoleWnd::TextOut(constchar*pstr){for(;*pstr;++pstr)putchar(*pstr);return0;}////intCCons
8、oleWnd::CharOut(intx,inty,constintpstr)//Outputacharat(x,y)//intCConsoleWnd::CharOut(intx,inty,constintpstr){GotoXY(x,y);returnputchar(pstr);}////intCConsoleWnd::TextOut(constchar*pstr)//Outputastringat(x,y)//intCConsoleWnd::TextOut(intx,inty,constchar*pstr){GotoXY(x,y);returnTextOu
9、t(pstr);}文案大全實(shí)用文檔//}}//-------------------------------------------------------------//ApplicationclassclassCSLGame:publicCConsoleWnd{private:private:intcurX,curY;intpoolWidth,poolHeight;intbm_gamepool[GAME_MAX_HEIGHT+2][GAME_MAX_WIDTH+2];public:CSLGame():curX(0),curY(0){poolWidth=po
10、olHeight=0;}intInit