1
C
语言课程设计
_
扫雷游戏设计
/*5.3.4
源程?/p>
*/
#include <graphics.h>
#include <stdlib.h>
#include <dos.h>
#define LEFTPRESS 0xff01
#define LEFTCLICK 0xff10
#define LEFTDRAG 0xff19
#define MOUSEMOVE 0xff08
struct
{
int num;/*
格子当前处于什么状?/p>
,1
有雷?/p>
0
已经显示过数字或者空白格?/p>
*/
int roundnum;/*
统计格子周围有多少雷
*/
int flag;/*
右键按下显示红旗的标?/p>
,0
没有红旗标志
,1
有红旗标?/p>
*/
}Mine[10][10];
int gameAGAIN=0;/*
是否重来的变?/p>
*/
int gamePLAY=0;/*
是否是第一次玩游戏的标?/p>
*/
int mineNUM;/*
统计处理过的格子?/p>
*/
char randmineNUM[3];/*
显示数字的字符串
*/
int Keystate;
int MouseExist;
int MouseButton;
int MouseX;
int MouseY;
void Init(void);/*
图形驱动
*/
void MouseOn(void);/*
鼠标光标显示
*/
void MouseOff(void);/*
鼠标光标隐藏
*/
void MouseSetXY(int,int);/*
设置当前位置
*/
int
LeftPress(void);/*
左键按下
*/
int
RightPress(void);/*
鼠标右键按下
*/
void MouseGetXY(void);/*
得到当前位置
*/
void Control(void);/*
游戏开?/p>
,
重新
,
关闭
*/
void GameBegain(void);/*
游戏开始画?/p>
*/
void DrawSmile(void);/*
画笑?/p>
*/
void DrawRedflag(int,int);/*
显示红旗
*/
void DrawEmpty(int,int,int,int);/*
两种空格子的显示
*/
void GameOver(void);/*
游戏结束
*/
void GameWin(void);/*
显示胜利
*/
int
MineStatistics(int,int);/*
统计每个格子周围的雷?/p>
*/
int
ShowWhite(int,int);/*
显示无雷区的空白部分
*/
void GamePlay(void);/*
游戏过程
*/
void Close(void);/*
图形关闭
*/
void main(void)
{
Init();
Control();
Close();
}
void Init(void)/*
图形开?/p>
*/
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
}
void Close(void)/*
图形关闭
*/
{
closegraph();