版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、所需头文件 和 头文件的安装方法请到网上下载/*/* 著作权所有者 : */* 文件名 : 扫雷.cpp */* 内容 : 对排好序的文件进行检索 */* 作成日期 作者 : */* 修正日期 作者 : */*/#include#include #include #include#include#include #includepthread_t thread2;pthread_mutex_t mut;MOUSEMSG m;int *a;/一个用于分配空间的指针int post;/初始化不同等级雷的数量int size;/不同等级分配不同内存空间int shenyumine;/记录剩余雷的数量
2、int *two;/记录每个位置旁边有多少雷,0代表无雷,9代表当前位置是雷int *twotemp;/记录当前位置是否被鼠标左键点击int *numflags;/记录当前位置鼠标右键是否点击int timerm=0;/内置计时器 的分钟数int timers=0;/内置计时器 的秒数int controltime=0; int center_x=0;int center_y=0;int classsign=1;/定义游戏等级 且默认状态 为低级int leftdownsign;/记录int gameend; /标记游戏是否结束int returnend=0;/标记是否点击返回按钮int re
3、starttimer;/标记是否点击重新开始 以清零计时器clock_t time_start,time_stop; /标记游戏开始到结束所用时间float score;/记录游戏分数int lable;/标签控制鼠标点击时对应的不同页面IMAGE p;/读取图片 鼠标未指向状态IMAGE p11;/读取图片 鼠标指向状态IMAGE p1;/读取图片 鼠标未指向状态IMAGE p21;/读取图片 鼠标指向状态IMAGE p2;IMAGE p31;IMAGE p3;IMAGE p41;IMAGE c;IMAGE c1;IMAGE c11;IMAGE c2;IMAGE c21;IMAGE c3;I
4、MAGE c31;IMAGE f;IMAGE s;IMAGE t;IMAGE restarttemp;/读取图片 鼠标未指向状态IMAGE restart;IMAGE returtemp;/读取图片 鼠标指向状态IMAGE retur;IMAGE zero;/读取旁边地雷数量图标IMAGE one;IMAGE two1;IMAGE three;IMAGE four;IMAGE five;IMAGE six;IMAGE seven;IMAGE eight;IMAGE mine;/读取地雷IMAGE shenyu; /隐蔽计数显示IMAGE suremax;IMAGE suremaxtemp;IM
5、AGE clearrecod;IMAGE clearrecodtemp;void mouseaction();void ginterface();void mianinterface();void random();void addtion();void autoshow(int x,int y,int temp);void autoshowtemp(int x,int y,int temp,int a,int b,int c);void showshenyuminenum();void maxscore(int score,int sign);void thread_create();voi
6、d clearrecodfile();void suregameend();void autoshowtip(int x,int y,int temp);void autoshowtemptiptemp(int x,int y,int temp,int a,int b,int c);void autoshowreturntemp(int x,int y,int temp,int a,int b,int c);void autoshowreturn(int x,int y,int temp);int scanautoshow(int x,int y,int temp);int scanautos
7、howtemp(int x,int y,int temp,int a,int b,int c);void getclass()/得到游戏等级函数putimage(270,80,&c);putimage(270,80,&c1);putimage(270,175,&c2);putimage(270,285,&c3);lable=2;mouseaction();void mouseaction()/鼠标控制 游戏界面int sign=0;/标记鼠标该函数是否退出int flagsnum=0;/插入旗帜的个数int temp;/记录当前等级下雷盘的行数if(classsign=1)temp=6;if(
8、classsign=2)temp=9;if(classsign=3)temp=10;while(1)m=GetMouseMsg(); /得到鼠标当前状态 如没有状态则等待switch(m.uMsg)case WM_MOUSEMOVE:/移动鼠标if(lable=1)/主界面if(m.x=270&m.x=80&m.y=115) /确定鼠标当前位置是否在相应范围内putimage(270,80,&p11);if(m.x370)|(m.y115)putimage(270,80,&p);if(m.x=270&m.x=220&m.y=255)putimage(270,220,&p21);if(m.x37
9、0)|(m.y255)putimage(270,220,&p3);if(m.x=270&m.x=150&m.y=185)putimage(270,150,&p41);if(m.x370)|(m.y185)putimage(270,150,&p2);if(m.x=270&m.x=290&m.y=325)putimage(270,290,&p31);if(m.x370)|(m.y325)putimage(270,290,&p1);if(lable=2)/等级设置if(m.x=270&m.x=80&m.y=120)putimage(270,80,&c11);if(m.x370)|(m.y120)pu
10、timage(270,80,&c1);if(m.x=270&m.x=175&m.y=215)putimage(270,175,&c21);if(m.x370)|(m.y215)putimage(270,175,&c2);if(m.x=270&m.x=285&m.y=325)putimage(270,285,&c31);if(m.x370)|(m.y325)putimage(270,285,&c3);if(lable=3)/游戏界面if(m.x=130&m.x=400&m.y=440)putimage(130,400,&restarttemp);if(m.x250)|(m.y440)putima
11、ge(130,400,&restart);if(m.x=350&m.x=400&m.y=440)putimage(350,400,&returtemp);if(m.x470)|(m.y440)putimage(350,400,&retur);if(lable=4)/最高记录界面if(m.x=150&m.x=400&m.y=380&m.x=400&m.y=270&m.x=220&m.y=270&m.x=150&m.y=270&m.x=80&m.y=270&m.x=290&m.y=270&m.x=80&m.y=270&m.x=175&m.y=270&m.x=285&m.y=150&m.x=50&m
12、.y=(50+temp*30)&leftdownsign=0&gameend=0)/判断鼠标位置并确定游戏是否结束和 当前位置是否被鼠标左键点击/printf(%d %d %dn,*(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);aut
13、oshow(m.x,m.y,temp);else if(*(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);else if(*(two+(m.x-150)/30)+(m.y-50)/30)*temp)=2&*(twotemp+(m.x-150)/30)+(m.y-50)/30)*t
14、emp)=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,&two1);else if(*(two+(m.x-150)/30)+(m.y-50)/30)*temp)=3&*(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,&three
15、);else if(*(two+(m.x-150)/30)+(m.y-50)/30)*temp)=4&*(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,&four);else if(*(two+(m.x-150)/30)+(m.y-50)/30)*temp)=5&*(twotemp+(m.x-150)/30)+(m.y-50)/30)*temp)=0)*(twotemp+
16、(m.x-150)/30)+(m.y-50)/30)*temp)=1;putimage(m.x-150)/30)*30+150,(m.y-50)/30)*30+50,&five);else if(*(two+(m.x-150)/30)+(m.y-50)/30)*temp)=6&*(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,&six);else if(*(two+(m.
17、x-150)/30)+(m.y-50)/30)*temp)=7&*(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,&seven);else if(*(two+(m.x-150)/30)+(m.y-50)/30)*temp)=8&*(twotemp+(m.x-150)/30)+(m.y-50)/30)*temp)=0)*(twotemp+(m.x-150)/30)+(m.y
18、-50)/30)*temp)=1;putimage(m.x-150)/30)*30+150,(m.y-50)/30)*30+50,&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();elsetime_stop=clock(); /挖到地雷 游戏结束 计时器得到当前时间for(int i=0;itemp;i+)for(in
19、t j=0;j=130&m.x=400&m.y=350&m.x=400&m.y=150&m.x=400&m.y=380&m.x=400&m.y=150&m.x=50&m.y=(50+temp*30)&*(numflags+(m.x-150)/30)+(m.y-50)/30)*temp)=0&*(twotemp+(m.x-150)/30)+(m.y-50)/30)*temp)=0&gameend=0)/判断当前位置是否被右键和左键点击和自动翻开putimage(m.x-150)/30)*30+150,(m.y-50)/30)*30+50,&f);*(numflags+(m.x-150)/30)+
20、(m.y-50)/30)*temp)=1;/记录当前位置已被右键点击/printf(x=%d,y=%dn,(m.y-50)/30),(m.x-150)/30);shenyumine-;/点击后重置剩余雷的数量showshenyuminenum();/*int findminenum=0;/记录游戏着 正确定位地雷的个数for(int i=0;itemp;i+)for(int j=0;jtemp;j+)if(*(numflags+i*temp+j)=1&*(two+i*temp+j)=9)findminenum+;/printf(%d %d ,*(numflags+i*temp+j),*(two
21、+i*temp+j);j=0;/printf(n);if(findminenum=post&shenyumine=0&gameend=0)time_stop=clock();leftdownsign=1;outtextxy(150,450,恭喜你 地雷已全部清除);outtextxy(150,370,你的得分为:);/score=(double)(time_stop-time_start)/CLOCKS_PER_SEC;char scoretemp5;if(classsign=1)score=1000-6*score;if(score=0)score=0;else if(classsign=2)score=1000-3*score;if(score=0)score=0;if(classsign=3)score=1000-score;if(score=0)score=0;/printf(%f %f %d n,score,(double)(time_stop-time_start)/
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 福利院开展足球比赛活动方案
- 电子商务行业跨境电商与物流方案
- 力学计算题考试题库及答案
- 织金社区考试真题及答案
- 学校意识形态工作责任制落实方案
- 2025年临床执业医师《内科学》卷
- 野生动植物保护规范考核试题及答案
- 医疗机构消防安全知识岗前培训试题及答案
- 医疗机构职业病防治法培训试题及答案
- 191公司例会部门会议模板
- 清运垃圾考试试题及答案
- 酒店公共场所卫生知识试卷(含答案)
- 2025年中学生守则及中学生日常行为规范
- DB13∕T 5354-2021 中小型线状水利工程地质勘察规范
- (2025年标准)桉树购销协议书
- 教师企业锻炼方案及实践指导
- 轨道交通专业认知试题带答案
- 植物细胞壁的结构特点与生理功能
- 学生退学申请表
- 无菌技术操作消毒隔离常识
- 上海市幼儿园装备指南(试行)
评论
0/150
提交评论