数据结构扫雷实训源代码文档格式.docx
- 文档编号:22855793
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:74
- 大小:27.86KB
数据结构扫雷实训源代码文档格式.docx
《数据结构扫雷实训源代码文档格式.docx》由会员分享,可在线阅读,更多相关《数据结构扫雷实训源代码文档格式.docx(74页珍藏版)》请在冰豆网上搜索。
//记录每个位置旁边有多少雷,0代表无雷,9代表当前位置是雷
int*twotemp;
//记录当前位置是否被鼠标左键点击
int*numflags;
//记录当前位置鼠标右键是否点击
inttimerm=0;
//内置计时器的分钟数
inttimers=0;
//内置计时器的秒数
intcontroltime=0;
intcenter_x=0;
intcenter_y=0;
intclasssign=1;
//定义游戏等级且默认状态为低级
intleftdownsign;
//记录
intgameend;
//标记游戏是否结束
intreturnend=0;
//标记是否点击返回按钮
intrestarttimer;
//标记是否点击重新开始以清零计时器
clock_ttime_start,time_stop;
//标记游戏开始到结束所用时间
floatscore;
//记录游戏分数
intlable;
//标签控制鼠标点击时对应的不同页面
IMAGEp;
//读取图片鼠标未指向状态
IMAGEp11;
//读取图片鼠标指向状态
IMAGEp1;
//读取图片鼠标未指向状态
IMAGEp21;
//读取图片鼠标指向状态
IMAGEp2;
IMAGEp31;
IMAGEp3;
IMAGEp41;
IMAGEc;
IMAGEc1;
IMAGEc11;
IMAGEc2;
IMAGEc21;
IMAGEc3;
IMAGEc31;
IMAGEf;
IMAGEs;
IMAGEt;
IMAGErestarttemp;
IMAGErestart;
IMAGEreturtemp;
//读取图片鼠标指向状态
IMAGEretur;
IMAGEzero;
//读取旁边地雷数量图标
IMAGEone;
IMAGEtwo1;
IMAGEthree;
IMAGEfour;
IMAGEfive;
IMAGEsix;
IMAGEseven;
IMAGEeight;
IMAGEmine;
//读取地雷
IMAGEshenyu;
//隐蔽计数显示
IMAGEsuremax;
IMAGEsuremaxtemp;
IMAGEclearrecod;
IMAGEclearrecodtemp;
voidmouseaction();
voidginterface();
voidmianinterface();
voidrandom();
voidaddtion();
voidautoshow(intx,inty,inttemp);
voidautoshowtemp(intx,inty,inttemp,inta,intb,intc);
voidshowshenyuminenum();
voidmaxscore(intscore,intsign);
voidthread_create();
voidclearrecodfile();
voidsuregameend();
voidautoshowtip(intx,inty,inttemp);
voidautoshowtemptiptemp(intx,inty,inttemp,inta,intb,intc);
voidautoshowreturntemp(intx,inty,inttemp,inta,intb,intc);
voidautoshowreturn(intx,inty,inttemp);
intscanautoshow(intx,inty,inttemp);
intscanautoshowtemp(intx,inty,inttemp,inta,intb,intc);
voidgetclass()//得到游戏等级函数
{
putimage(270,80,&
c);
c1);
putimage(270,175,&
c2);
putimage(270,285,&
c3);
lable=2;
mouseaction();
}
voidmouseaction()//鼠标控制游戏界面
intsign=0;
//标记鼠标该函数是否退出
intflagsnum=0;
//插入旗帜的个数
inttemp;
//记录当前等级下雷盘的行数
if(classsign==1)
{
temp=6;
}
if(classsign==2)
temp=9;
if(classsign==3)
temp=10;
while
(1)
m=GetMouseMsg();
//得到鼠标当前状态如没有状态则等待
switch(m.uMsg)
{
caseWM_MOUSEMOVE:
//移动鼠标
if(lable==1)//主界面
{
if(m.x>
=270&
&
m.x<
=370&
m.y>
=80&
m.y<
=115)//确定鼠标当前位置是否在相应范围内
{
putimage(270,80,&
p11);
}
if(((m.x<
270||m.x>
370)||(m.y<
80||m.y>
115)))
p);
=220&
=255)
putimage(270,220,&
p21);
220||m.y>
255)))
p3);
=150&
=185)
putimage(270,150,&
p41);
150||m.y>
185)))
p2);
=290&
=325)
putimage(270,290,&
p31);
290||m.y>
325)))
p1);
}
if(lable==2)//等级设置
=120)
c11);
120)))
=175&
=215)
putimage(270,175,&
c21);
175||m.y>
215)))
=285&
putimage(270,285,&
c31);
285||m.y>
if(lable==3)//游戏界面
=130&
=250&
=400&
=440)
putimage(130,400,&
restarttemp);
130||m.x>
250)||(m.y<
400||m.y>
440)))
restart);
=350&
=470&
putimage(350,400,&
returtemp);
350||m.x>
470)||(m.y<
retur);
if(lable==4)//最高记录界面
=430)
putimage(150,400,&
suremaxtemp);
else
suremax);
=380&
=500&
putimage(380,400,&
clearrecodtemp);
clearrecod);
break;
caseWM_LBUTTONDOWN:
//点击鼠标左键
if(classsign==1)
temp=6;
if(classsign==2)
temp=9;
if(classsign==3)
temp=10;
sign=1;
getclass();
maxscore(2,1);
=115)
returnend=0;
time_start=clock();
//记录游戏开始时间
thread_create();
//创建多线程为实现计时器和游戏同时运行
//random();
//addtion();
//ginterface();
//closegraph();
exit(0);
if(lable==2)//等级界面
classsign=1;
lable=1;
loadimage(NULL,"
images\\maininterface.jpg"
);
//输出获取的图像
mouseaction();
classsign=2;
classsign=3;
=(150+temp*30)&
=50&
=(50+temp*30)&
leftdownsign==0&
gameend==0)//判断鼠标位置并确定游戏是否结束和当前位置是否被鼠标左键点击
//printf("
%d%d%d\n"
*(two+((m.x-150)/30)+((m.y-50)/30)*temp),(m.y-50)/30,((m.x-150)/30));
if(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)!
=9)
{
if(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==0)
//putimage(((m.x-150)/30)*30+150,((m.y-50)/30)*30+50,&
s);
autoshow(m.x,m.y,temp);
elseif(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==1&
*(twotemp+((m.x-150)/30)+((m.y-50)/30)*temp)==0)
{
*(twotemp+((m.x-150)/30)+((m.y-50)/30)*temp)=1;
putimage(((m.x-150)/30)*30+150,((m.y-50)/30)*30+50,&
one);
}
elseif(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==2&
two1);
elseif(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==3&
three);
elseif(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==4&
four);
elseif(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==5&
five);
elseif(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==6&
six);
elseif(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==7&
seven);
elseif(*(two+((m.x-150)/30)+((m.y-50)/30)*temp)==8&
eight);
if(*(numflags+((m.x-150)/30)+((m.y-50)/30)*temp)==1)
*(numflags+((m.x-150)/30)+((m.y-50)/30)*temp)=0;
shenyumine++;
//取消有雷状态重新计算雷德数量
showshenyuminenum();
suregameend();
}
else
time_stop=clock();
//挖到地雷游戏结束计时器得到当前时间
for(inti=0;
i<
temp;
i++)
for(intj=0;
j<
j++)
{
if(*(two+temp*i+j)==9)
putimage(150+j*30,50+30*i,&
mine);
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据结构 扫雷 源代码