废话不多说,直接上代码,看官们先去试试,然后回来看分析
分析文章见:
https://blog.csdn.net/ycczbasd/article/details/103511457
#include <iostream>
#include <windows.h>
#include <time.h>
#include <vector>
using namespace std;
void GameInit();
void GameRun();
void GameDraw();
void GameLogic();
void GameEnd();
void SetThunderPosition();
void CountThunder();
void Spread(int index);
void ShowCompleteMap();
HANDLE hOutput;
COORD coord = { 0,0 };
int MapW = 0;
int MapH = 0;
int MapS = 0;
//0空白;
//1代表该位置附近有1颗雷,最多有8颗
//9代表该位置有雷
//-9代表该位置的雷被排除了
char* Map; //地图动态数组
char* DisplayMap;//屏幕展示出来的地图
int* ThunderIndex; //雷位置索引动态数组
int difficult = 0;
bool isRun = true;
int ThunderNum = 0; //雷数量
//Game光标
int CursonX = 0;
int CursonY = 0;
char pic[][3] = { "□","①","②","③","④","⑤","⑥","⑦","⑧","⊕","▶","■","↖" };
//游戏状态 0:开始场景 1:难度选择场景 2:游戏运行场景 3:胜利场景 4:失败场景 5:游戏结束场景
int status = 0;
void main()
{
int input;
hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
//隐藏缓冲区的光标
CONSOLE_CURSOR_INFO cci;
cci.bVisible = 0;
cci.dwSize = 1;
SetConsoleCursorInfo(hOutput, &cci);
while (isRun)
{
system("cls");
if (status == 0)
{
cout << "请选择:\n" << "1.开始\n" << "2.退出\n" << "