File indexing completed on 2024-05-05 08:05:18
0001 /*************************************************************************** 0002 * KBlocks, a falling blocks game by KDE * 0003 * SPDX-FileCopyrightText: 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> * 0004 * * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 ***************************************************************************/ 0007 #ifndef KBLOCKSPIECE_H 0008 #define KBLOCKSPIECE_H 0009 0010 #include "PieceInterface.h" 0011 0012 #define KBlocksPiece_CellCount 4 0013 0014 enum KBlocks_PieceType { 0015 PieceType_Shape_Z = 0, 0016 PieceType_Shape_S, 0017 PieceType_Shape_I, 0018 PieceType_Shape_T, 0019 PieceType_Shape_O, 0020 PieceType_Shape_L, 0021 PieceType_Shape_J, 0022 PieceType_Max_Count 0023 }; 0024 0025 enum KBlocks_PieceRotation { 0026 PieceRotation_Up = 0, 0027 PieceRotation_Left, 0028 PieceRotation_Down, 0029 PieceRotation_Right, 0030 PieceRotation_Max_Count 0031 }; 0032 0033 enum KBlocks_PieceType_Detail { 0034 PieceType_Shape_Z_1 = 0, 0035 PieceType_Shape_Z_2, 0036 PieceType_Shape_Z_3, 0037 PieceType_Shape_Z_4, 0038 PieceType_Shape_S_1, 0039 PieceType_Shape_S_2, 0040 PieceType_Shape_S_3, 0041 PieceType_Shape_S_4, 0042 PieceType_Shape_I_1, 0043 PieceType_Shape_I_2, 0044 PieceType_Shape_I_3, 0045 PieceType_Shape_I_4, 0046 PieceType_Shape_T_1, 0047 PieceType_Shape_T_2, 0048 PieceType_Shape_T_3, 0049 PieceType_Shape_T_4, 0050 PieceType_Shape_O_1, 0051 PieceType_Shape_O_2, 0052 PieceType_Shape_O_3, 0053 PieceType_Shape_O_4, 0054 PieceType_Shape_L_1, 0055 PieceType_Shape_L_2, 0056 PieceType_Shape_L_3, 0057 PieceType_Shape_L_4, 0058 PieceType_Shape_J_1, 0059 PieceType_Shape_J_2, 0060 PieceType_Shape_J_3, 0061 PieceType_Shape_J_4, 0062 PieceType_Detail_Max_Count 0063 }; 0064 0065 class PiecePoint 0066 { 0067 public: 0068 PiecePoint(int x, int y); 0069 ~PiecePoint(); 0070 0071 public: 0072 int x(); 0073 int y(); 0074 0075 private: 0076 int mPosX; 0077 int mPosY; 0078 }; 0079 0080 class KBlocksPiece : public PieceInterface 0081 { 0082 public: 0083 KBlocksPiece(); 0084 explicit KBlocksPiece(PieceInterface *p); 0085 ~KBlocksPiece() override; 0086 0087 public: 0088 void copy(PieceInterface *p); 0089 0090 int toValue() override; 0091 void fromValue(int val); 0092 0093 int getType() override; 0094 void setType(int newType); 0095 0096 int getRotation() override; 0097 void setRotation(int newRotation); 0098 0099 int getPosX() override; 0100 void setPosX(int newPosX); 0101 0102 int getPosY() override; 0103 void setPosY(int newPosY); 0104 0105 int getCellCount() override; 0106 int getCellPosX(int index) override; 0107 int getCellPosY(int index) override; 0108 0109 int getWidth(); 0110 int getHeight(); 0111 int getRotationCount() override; 0112 0113 int getSignature(int *signature); 0114 0115 void encodeData(unsigned char *data); 0116 void decodeData(unsigned char *data); 0117 }; 0118 0119 #endif 0120