15 Star 30 Fork 8

slowrookie/Qt-Tetrix

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
tetrixpiece.h 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
slowrookie 提交于 2013-11-11 10:25 . create push
#ifndef TETRIXPIECE_H
#define TETRIXPIECE_H
//改形状的顺序与coordsTable所对应的形状一致
enum TetrixShape {NOShape,IShape,OShape,TShape,LShape,JShape,SShape,ZShape};
//朝向 coordsTable 从上之下的朝向均为顺时针
enum TetrixDirection {UP,RIGHT,DOWN,LEFT};
//Size
enum TetrixSize{SquareHeight = 20 , SquareWidth = 20};
class TetrixPiece
{
public:
//初始化
TetrixPiece(){setShape(NOShape);}
//设置Shape
void setShape(TetrixShape tetrixShape,TetrixDirection tetrixDirection = UP);
void setRandomShape();
TetrixShape shape(){return pieceShape;}
TetrixDirection direction(){return pieceDirection;}
//顺时针旋转
TetrixPiece rotateRight() const;
//逆时针选择
TetrixPiece rotateLeft() const;
int value(int x, int y) const {return coords[x][y];}
int getHeight() const;
int getWidth() const;
int x() const;
int y() const;
private:
TetrixShape pieceShape;
TetrixDirection pieceDirection;
//当前形状
int coords[4][4];
};
#endif // TETRIXPIECE_H
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/slowrookie/Qt-Tetrix.git
git@gitee.com:slowrookie/Qt-Tetrix.git
slowrookie
Qt-Tetrix
Qt-Tetrix
master

搜索帮助