1 Star 0 Fork 8

fdmdf/Qt-Tetrix

forked from slowrookie/Qt-Tetrix 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tetrixboard.h 1.36 KB
一键复制 编辑 原始数据 按行查看 历史
fdmdf 提交于 2021-07-23 13:33 . null
#ifndef TETRIXBOARD_H
#define TETRIXBOARD_H
#include <QFrame>
#include <QPainter>
#include <QBasicTimer>
#include <QLabel>
#include <QPointer>
#include "tetrixpiece.h"
class TetrixBoard : public QFrame
{
Q_OBJECT
public:
TetrixBoard(QWidget *parent = 0);
void setNextPieceLabel(QLabel *label);
public slots:
void pause();
void start();
signals:
void levelChanged(int level);
void scoreChanged(int score);
protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
void timerEvent(QTimerEvent *event);
private:
//定义方块活动窗体的列数、行数
enum {BoardWidth = 18 ,BoardHeight = 30};
enum {GameBoardBorder = 1};
//画出一个方块
void drawSquare(QPainter &painter,int x,int y,TetrixShape shape);
//移动方法
bool tryMove(const TetrixPiece &newPiece,int newX,int newY);
void pieceDroped();
TetrixShape &shapeAt(int x, int y){return coordsBoard[x][y];}
void newPiece();
void clearBoard();
void removeFullLines();
void dropDown();
void showNextPiece();
TetrixPiece currentPiece;
TetrixPiece nextPiece;
QPointer<QLabel> nextPieceLabel;
int curX;
int curY;
bool isPaused;
bool isStarted;
TetrixShape coordsBoard[BoardWidth][BoardHeight];
QBasicTimer timer;
int level;
int score;
};
#endif // TETRIXBOARD_H
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/fdmdf/Qt-Tetrix.git
git@gitee.com:fdmdf/Qt-Tetrix.git
fdmdf
Qt-Tetrix
Qt-Tetrix
master

搜索帮助