1/***************************************************************************
2* KBlocks, a falling blocks game for KDE *
3* Copyright (C) 2010 Zhongjie Cai <squall.leonhart.cai@gmail.com> *
4* *
5* This program is free software; you can redistribute it and/or modify *
6* it under the terms of the GNU General Public License as published by *
7* the Free Software Foundation; either version 2 of the License, or *
8* (at your option) any later version. *
9***************************************************************************/
10#ifndef KBLOCKSPIECE_H
11#define KBLOCKSPIECE_H
12
13#include "PieceInterface.h"
14
15#define KBlocksPiece_CellCount 4
16
17enum KBlocks_PieceType
18{
19 PieceType_Shape_Z = 0,
20 PieceType_Shape_S,
21 PieceType_Shape_I,
22 PieceType_Shape_T,
23 PieceType_Shape_O,
24 PieceType_Shape_L,
25 PieceType_Shape_J,
26 PieceType_Max_Count
27};
28
29enum KBlocks_PieceRotation
30{
31 PieceRotation_Up = 0,
32 PieceRotation_Left,
33 PieceRotation_Down,
34 PieceRotation_Right,
35 PieceRotation_Max_Count
36};
37
38enum KBlocks_PieceType_Detail
39{
40 PieceType_Shape_Z_1 = 0,
41 PieceType_Shape_Z_2,
42 PieceType_Shape_Z_3,
43 PieceType_Shape_Z_4,
44 PieceType_Shape_S_1,
45 PieceType_Shape_S_2,
46 PieceType_Shape_S_3,
47 PieceType_Shape_S_4,
48 PieceType_Shape_I_1,
49 PieceType_Shape_I_2,
50 PieceType_Shape_I_3,
51 PieceType_Shape_I_4,
52 PieceType_Shape_T_1,
53 PieceType_Shape_T_2,
54 PieceType_Shape_T_3,
55 PieceType_Shape_T_4,
56 PieceType_Shape_O_1,
57 PieceType_Shape_O_2,
58 PieceType_Shape_O_3,
59 PieceType_Shape_O_4,
60 PieceType_Shape_L_1,
61 PieceType_Shape_L_2,
62 PieceType_Shape_L_3,
63 PieceType_Shape_L_4,
64 PieceType_Shape_J_1,
65 PieceType_Shape_J_2,
66 PieceType_Shape_J_3,
67 PieceType_Shape_J_4,
68 PieceType_Detail_Max_Count
69};
70
71class PiecePoint
72{
73 public:
74 PiecePoint(int x, int y);
75 ~PiecePoint();
76
77 public:
78 int x();
79 int y();
80
81 private:
82 int mPosX;
83 int mPosY;
84};
85
86class KBlocksPiece : public PieceInterface
87{
88 public:
89 KBlocksPiece();
90 KBlocksPiece(PieceInterface * p);
91 ~KBlocksPiece();
92
93 public:
94 void copy(PieceInterface * p);
95
96 int toValue();
97 void fromValue(int val);
98
99 int getType();
100 void setType(int newType);
101
102 int getRotation();
103 void setRotation(int newRotation);
104
105 int getPosX();
106 void setPosX(int newPosX);
107
108 int getPosY();
109 void setPosY(int newPosY);
110
111 int getCellCount();
112 int getCellPosX(int index);
113 int getCellPosY(int index);
114
115 int getWidth();
116 int getHeight();
117 int getRotationCount();
118
119 int getSignature(int * signature);
120
121 void encodeData(unsigned char * data);
122 void decodeData(unsigned char * data);
123
124 protected:
125 int mType;
126 int mPosX;
127 int mPosY;
128 int mRotation;
129};
130
131#endif
132
133