QT版黑白棋


在 凌阳培训做的。
资源截图
代码片段和文件信息
#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  othello2

     文件       8015  2012-10-23 18:38  othello2.png

     文件       5947  2012-10-23 18:38  othello21.png

     文件      10100  2012-10-23 18:40  othello210.png

     文件       6729  2012-10-23 18:40  othello211.png

     文件       9741  2012-10-23 18:40  othello212.png

     文件      10031  2012-10-23 18:40  othello213.png

     文件       9348  2012-10-23 18:40  othello214.png

     文件       9876  2012-10-23 18:40  othello215.png

     文件      10183  2012-10-23 18:41  othello216.png

     文件       8523  2012-10-23 18:41  othello217.png

     文件      10235  2012-10-23 18:42  othello218.png

     文件       9911  2012-10-23 18:42  othello219.png

     文件       7640  2012-10-23 18:38  othello22.png

     文件      11471  2012-10-23 18:42  othello220.png

     文件       9727  2012-10-23 18:42  othello221.png

     文件       8501  2012-10-23 18:42  othello222.png

     文件      11266  2012-10-23 18:42  othello223.png

     文件      11043  2012-10-23 18:42  othello224.png

     文件      11240  2012-10-23 18:43  othello225.png

     文件      11547  2012-10-23 18:43  othello226.png

     文件      10120  2012-10-23 18:43  othello227.png

     文件      11506  2012-10-23 18:43  othello228.png

     文件      11149  2012-10-23 18:43  othello229.png

     文件       7941  2012-10-23 18:38  othello23.png

     文件      11682  2012-10-23 18:44  othello230.png

     文件      10085  2012-10-23 18:44  othello231.png

     文件      11297  2012-10-23 18:44  othello232.png

     文件       8705  2012-10-23 18:44  othello233.png

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

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)