• 大小: 14.27MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-14
  • 语言: 其他
  • 标签: 黑白棋  

资源简介

在 凌阳培训做的。

资源截图

代码片段和文件信息

#include “chessboardwidget.h“
#include 
//#include 
//#include 


ChessboardWidget::ChessboardWidget(QWidget *parent)
    : QWidget(parent)
{
    this->pos.setX(-1);
    this->pos.setY(-1);
    bout = 0;
    press_flag = 0;
    help_flag = 0;
    input_flag = BLACK_IN;
    gridNum = 8;
    white_gride = 0;
    black_gride = 0;
    play_time = 10;
    wid = this->width()/(gridNum+2);
    hig = this->height()/(gridNum+2);
    blank_x = 0;
    blank_y = 0;
    play_flag = 0;
    goback_flag = 0 ;
    max_x = 0;
    max_y = 0;
    pause_flag = false;

    this->playback_time = new QTimer();
    this->pvmdelay = new QTimer();
    playback_bout = 0;
    connect(this->playback_timeSIGNAL(timeout())thisSLOT(play()));
    connect(this->pvmdelaySIGNAL(timeout())thisSLOT(pvm_delay()));





    int ij;                //初始化chessboard
    for(i = 0;i    {
        for(j = 0;j        {
            this->chess[0][i][j] = EMPTY;
            this->help_chess[i][j] = EMPTY;
        }
    }

    chess[0][3][3] = BLACK;
    chess[0][4][4] = BLACK;
    chess[0][3][4] = WHITE;
    chess[0][4][3] =  WHITE;
    this->setMouseTracking(true);
}

ChessboardWidget::~ChessboardWidget()
{

}


void ChessboardWidget::paintEvent(QPaintEvent *ev)
{
    QPainter  paint(this);


    if(this->play_flag == 0)             //游戏没开始
    {
        return;
    }

    QPen pen;                            //初始化画笔事件
    pen.setColor(QColor(2550255));
    pen.setWidth(2);
    pen.setstyle(Qt::SolidLine);
    paint.setPen(pen);

    int i;
    wid = this->width()/(gridNum+2);
    hig = this->height()/(gridNum+2);
    for(i = 0; i<(gridNum+1);i++)
    {
      paint.drawLine(widhig*(i+1)9*widhig*(i+1));
      paint.drawLine(wid*(i+1)higwid*(i+1)9*hig);
    }

    if(this->play_flag == 1)
    {
        if(input_flag == BLACK_IN)
        {
          paint.drawPixmap(blank_x*widblank_y*higwidhig
                                QPixmap(“./image/black.png“));
        }
        else
        {
          paint.drawPixmap(blank_x*widblank_y*higwidhig
                                 QPixmap(“./image/white.png“));

        }
    }
    else
    {
        paint.drawPixmap(blank_x*widblank_y*higwidhig
                        QPixmap(“./image/black.png“));
    }

    if(true)
    {
        int ij;
        int temp_black = 0;
        int temp_white = 0;
        for(i = 0;i        {
            for(j = 0;j            {

                if(this->chess[bout][i][j] == BLACK)
                {

                  paint.drawPixmap((i+1)*wid(j+1)*higwidhig
                             QPixmap(“./image/black.png“));


                    temp_black++;
                }
                else if(this->chess[bout][i][j] == WHITE)
                {            
           

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

     目录          0  2013-04-21 13:51  othello

     目录          0  2013-04-21 13:51  othello\2

     文件       8015  2012-10-23 18:38  othello\2\0.png

     文件       5947  2012-10-23 18:38  othello\2\1.png

     文件      10100  2012-10-23 18:40  othello\2\10.png

     文件       6729  2012-10-23 18:40  othello\2\11.png

     文件       9741  2012-10-23 18:40  othello\2\12.png

     文件      10031  2012-10-23 18:40  othello\2\13.png

     文件       9348  2012-10-23 18:40  othello\2\14.png

     文件       9876  2012-10-23 18:40  othello\2\15.png

     文件      10183  2012-10-23 18:41  othello\2\16.png

     文件       8523  2012-10-23 18:41  othello\2\17.png

     文件      10235  2012-10-23 18:42  othello\2\18.png

     文件       9911  2012-10-23 18:42  othello\2\19.png

     文件       7640  2012-10-23 18:38  othello\2\2.png

     文件      11471  2012-10-23 18:42  othello\2\20.png

     文件       9727  2012-10-23 18:42  othello\2\21.png

     文件       8501  2012-10-23 18:42  othello\2\22.png

     文件      11266  2012-10-23 18:42  othello\2\23.png

     文件      11043  2012-10-23 18:42  othello\2\24.png

     文件      11240  2012-10-23 18:43  othello\2\25.png

     文件      11547  2012-10-23 18:43  othello\2\26.png

     文件      10120  2012-10-23 18:43  othello\2\27.png

     文件      11506  2012-10-23 18:43  othello\2\28.png

     文件      11149  2012-10-23 18:43  othello\2\29.png

     文件       7941  2012-10-23 18:38  othello\2\3.png

     文件      11682  2012-10-23 18:44  othello\2\30.png

     文件      10085  2012-10-23 18:44  othello\2\31.png

     文件      11297  2012-10-23 18:44  othello\2\32.png

     文件       8705  2012-10-23 18:44  othello\2\33.png

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

评论

共有 条评论