• / 20
  • 下载费用:10 金币  

扫雷游戏代码.doc

关 键 词:
扫雷游戏代码.doc
资源描述:
/*block.h*/#ifndef BLOCK_H_#define BLOCK_H_#includeclass QWidget;class Block:public QLabel{Q_OBJECTpublic:explicit Block(bool mine_flag,QWidget* parent=0);void set_number(int number);void turn_over();bool is_mine()const;bool is_turn_over()const;signals:void turn_over(bool is_mine);protected:void mousePressEvent(QMouseEvent* event);private:bool mine_flag_;bool mark_flag_;bool turn_over_flag_;int number_;};#endif#include“block.h“#include#include#include#includeBlock::Block(bool mine_flag,QWidget* parent):QLabel(parent){mine_flag_=mine_flag;mark_flag_=false;turn_over_flag_=false;number_=-1;setPixmap(QPixmap(“:/images/normal.png“));}void Block::set_number(int number){number_=number;}void Block::turn_over(){if(!turn_over_flag_){turn_over_flag_=true;if(mine_flag_)setPixmap(QPixmap(“:/images/mine.png“));elsesetPixmap(QPixmap(“:/images/mine_“+QString(“%1“).arg(number_)+“.png“));update();}}bool Block::is_mine()const{return mine_flag_;}bool Block::is_turn_over()const{return turn_over_flag_;}/*鼠标事件的实现*/void Block::mousePressEvent(QMouseEvent* event){if(event-button()==Qt::LeftButton){if(!turn_over_flag_if(mine_flag_==true){setPixmap(QPixmap(“:/images/mine.png“));update();emit turn_over(true);}else{setPixmap(QPixmap(“:/images/mine_“+QString(“%1“).arg(number_)+“.png“));update();emit turn_over(false);}}}else if(event-button()==Qt::RightButton){if(!turn_over_flag_){if(!mark_flag_){mark_flag_=true;setPixmap(QPixmap(“:/images/flag.png“));}else{mark_flag_=false;setPixmap(QPixmap(“:/images/normal.png“));}update();}}QLabel::mousePressEvent(event);}#ifndef BLOCK_AREA_H_#define BLOCK_AREA_H_#include“block.h“#includeclass QEvent;class QGridLayout;class QObject;class BlockArea:public QWidget{Q_OBJECTpublic:BlockArea(int row,int column,int mine_number,QWidget* parent=0);void set_block_area(int row,int column,int mine_number,int init_flag=false);signals:void game_over(bool is_win);protected:bool eventFilter(QObject* watched, QEvent* event);private slots:void slot_turn_over(bool is_mine);priv
展开阅读全文
  微传网所有资源均是用户自行上传分享,仅供网友学习交流,未经上传用户书面授权,请勿作他用。
0条评论

还可以输入200字符

暂无评论,赶快抢占沙发吧。

关于本文
本文标题:扫雷游戏代码.doc
链接地址:https://www.weizhuannet.com/p-10051840.html
微传网是一个办公文档、学习资料下载的在线文档分享平台!

微传网博客

网站资源均来自网络,如有侵权,请联系客服删除!

 网站客服QQ:80879498  会员QQ群:727456886

copyright@ 2018-2028 微传网络工作室版权所有

     经营许可证编号:冀ICP备18006529号-1 ,公安局备案号:13028102000124

收起
展开