Diffstat (limited to 'noncore/games/tetrix/tpiece.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/games/tetrix/tpiece.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/noncore/games/tetrix/tpiece.h b/noncore/games/tetrix/tpiece.h new file mode 100644 index 0000000..9c1c629 --- a/dev/null +++ b/noncore/games/tetrix/tpiece.h | |||
@@ -0,0 +1,62 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | |||
21 | |||
22 | #ifndef TPIECE_H | ||
23 | #define TPIECE_H | ||
24 | |||
25 | class TetrixPiece | ||
26 | { | ||
27 | public: | ||
28 | TetrixPiece() {setRandomType();} | ||
29 | TetrixPiece(int type) {initialize(type % 7 + 1);} | ||
30 | |||
31 | void setRandomType() {initialize(randomValue(7) + 1);} | ||
32 | |||
33 | void rotateLeft(); | ||
34 | void rotateRight(); | ||
35 | |||
36 | int getType() {return pieceType;} | ||
37 | int getXCoord(int index) {return coordinates[index][0];} | ||
38 | int getYCoord(int index) {return coordinates[index][1];} | ||
39 | void getCoord(int index,int &x,int&y){x = coordinates[index][0]; | ||
40 | y = coordinates[index][1];} | ||
41 | int getMinX(); | ||
42 | int getMaxX(); | ||
43 | int getMinY(); | ||
44 | int getMaxY(); | ||
45 | |||
46 | static void setRandomSeed(double seed); | ||
47 | static int randomValue(int maxPlusOne); | ||
48 | |||
49 | private: | ||
50 | void setXCoord(int index,int value) {coordinates[index][0] = value;} | ||
51 | void setYCoord(int index,int value) {coordinates[index][1] = value;} | ||
52 | void setCoords(int index,int x,int y){coordinates[index][0] = x; | ||
53 | coordinates[index][1] = y;} | ||
54 | void initialize(int type); | ||
55 | |||
56 | int pieceType; | ||
57 | int coordinates[4][2]; | ||
58 | |||
59 | static double randomSeed; | ||
60 | }; | ||
61 | |||
62 | #endif | ||