• 大小: 2.04MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-20
  • 语言: 其他
  • 标签: Qt  linux  扫雷  

资源简介

非常好的扫雷项目,注解清晰。用跨平台的工具qt 实现。 自己写的,项目有详细注释。

资源截图

代码片段和文件信息

#include “cellitem.h“
#include “sweepminesscene.h“
#include “sweepminesapp.h“
#include “field.h“
#include 
QPixmap * CellItem::initial    = 0;
QPixmap * CellItem::blank      = 0;
QPixmap * CellItem::question   = 0;
QPixmap * CellItem::flag       = 0;
QPixmap * CellItem::explode    = 0;
QPixmap * CellItem::digits[9]  = {0};

unsigned  CellItem::refCount = 0;

CellItem::CellItem(int xint y)
    :cx(x)
    cy(y)
    state(CIS_INITIAL)
{
    refCount++;
    if(refCount == 1)//在第一个items对像创建时,生成图片对像
    {
        initial   = new QPixmap(“:/image/initial.jpg“);
        blank     = new QPixmap(“:/image/blank.jpg“);
        question  = new QPixmap(“:/image/question.jpg“);
        flag      = new QPixmap(“:/image/flag.jpg“);
        explode   = new QPixmap(“:/image/explode.jpg“);

        QString preFix(“:/image/“);
        QString postFix(“.jpg“);
        QString fileNamenum;

        for(int i=1; i<9; i++)
        {
            num.setNum(i);
            fileName = preFix;
            fileName += num;
            fileName += postFix;

            digits[i] = new QPixmap(fileName);
        }


    }

    setPixmap(*initial);
}
CellItem::~CellItem()
{
    refCount--;
    if(refCount == 0)//在最后一个items对像销毁时,销毁图片对像
    {
        delete initial;
        delete blank;
        delete question;
        delete flag;
        delete explode;
        for(int i=1; i<9; i++)
        {
            delete digits[i];
        }

    }

}

void CellItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
    if(state == CIS_SWEPT)
        return ;
    switch(event->button())
    {
        case Qt::LeftButton:
            switch(state)
            {
                case CIS_INITIAL:
                    setPixmap(*blank);
                    break;
                case CIS_FLAG:
                    return ;
                case CIS_QUESTION:
                    setPixmap(*blank);
                    state = CIS_INITIAL;
                    break;
                default:
                    break;
            }
            break;
        case Qt::RightButton:
        {
            switch(state)
            {
                case CIS_INITIAL:
                    setPixmap(*flag);
                    state = CIS_FLAG;
                    break;
                case CIS_FLAG:
                    setPixmap(*question);
                    state = CIS_QUESTION;
                    break;
                case CIS_QUESTION:
                    setPixmap(*initial);
                    state = CIS_INITIAL;
                    break;
                default:
                    break;
            }
        }
           break;
        default:
            break;

    }
}
void CellItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    if(state == CIS_SWEPT||state == CIS_FLAG)
        return;
    switch(event->button())
    {
        case Qt::LeftButto

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4011  2013-03-10 10:31  SweepMines\cellitem.cpp

     文件        955  2013-03-10 10:30  SweepMines\cellitem.h

     文件     306413  2013-03-10 11:49  SweepMines\debug\cellitem.o

     文件     291202  2013-03-10 11:49  SweepMines\debug\field.o

     文件      37809  2013-03-10 11:49  SweepMines\debug\game.o

     文件     183772  2013-03-10 11:49  SweepMines\debug\main.o

     文件     249527  2013-03-10 12:06  SweepMines\debug\mainwindow.o

     文件     228304  2013-03-11 10:01  SweepMines\debug\minescustomdialog.o

     文件       3303  2013-03-10 11:49  SweepMines\debug\moc_mainwindow.cpp

     文件     186138  2013-03-10 11:49  SweepMines\debug\moc_mainwindow.o

     文件       2551  2013-03-10 15:03  SweepMines\debug\moc_minescustomdialog.cpp

     文件     191709  2013-03-10 15:03  SweepMines\debug\moc_minescustomdialog.o

     文件       2498  2013-03-10 11:49  SweepMines\debug\moc_sweepminesapp.cpp

     文件     128908  2013-03-10 11:49  SweepMines\debug\moc_sweepminesapp.o

     文件       2538  2013-03-10 11:49  SweepMines\debug\moc_sweepminesscene.cpp

     文件     188487  2013-03-10 11:49  SweepMines\debug\moc_sweepminesscene.o

     文件     655169  2013-03-10 11:49  SweepMines\debug\qrc_image.cpp

     文件     139473  2013-03-10 11:49  SweepMines\debug\qrc_image.o

     文件    6136031  2013-03-11 10:01  SweepMines\debug\SweepMines.exe

     文件     109653  2013-03-10 11:49  SweepMines\debug\sweepminesapp.o

     文件     391135  2013-03-10 14:33  SweepMines\debug\sweepminesscene.o

     文件       1838  2013-03-10 11:15  SweepMines\field.cpp

     文件        847  2013-03-10 11:13  SweepMines\field.h

     文件        117  2013-03-05 11:06  SweepMines\game.cpp

     文件        303  2013-03-05 12:03  SweepMines\game.h

     文件       9779  2011-08-03 19:41  SweepMines\image\1.jpg

     文件       9619  2011-08-03 19:41  SweepMines\image\2.jpg

     文件      10193  2011-08-03 19:41  SweepMines\image\3.jpg

     文件       9800  2011-08-03 19:40  SweepMines\image\4.jpg

     文件      10403  2011-08-03 19:40  SweepMines\image\5.jpg

............此处省略36个文件信息

评论

共有 条评论