| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: tpiece.h 160 2006-12-11 20:15:57Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
|
|---|
| 5 | **
|
|---|
| 6 | ** This file is part of an example program for Qt. This example
|
|---|
| 7 | ** program may be used, distributed and modified without limitation.
|
|---|
| 8 | **
|
|---|
| 9 | *****************************************************************************/
|
|---|
| 10 |
|
|---|
| 11 | #ifndef TPIECE_H
|
|---|
| 12 | #define TPIECE_H
|
|---|
| 13 |
|
|---|
| 14 | class TetrixPiece
|
|---|
| 15 | {
|
|---|
| 16 | public:
|
|---|
| 17 | TetrixPiece() {setRandomType();}
|
|---|
| 18 | TetrixPiece(int type) {initialize(type % 7 + 1);}
|
|---|
| 19 |
|
|---|
| 20 | void setRandomType() {initialize(randomValue(7) + 1);}
|
|---|
| 21 |
|
|---|
| 22 | void rotateLeft();
|
|---|
| 23 | void rotateRight();
|
|---|
| 24 |
|
|---|
| 25 | int getType() {return pieceType;}
|
|---|
| 26 | int getXCoord(int index) {return coordinates[index][0];}
|
|---|
| 27 | int getYCoord(int index) {return coordinates[index][1];}
|
|---|
| 28 | void getCoord(int index,int &x,int&y){x = coordinates[index][0];
|
|---|
| 29 | y = coordinates[index][1];}
|
|---|
| 30 | int getMinX();
|
|---|
| 31 | int getMaxX();
|
|---|
| 32 | int getMinY();
|
|---|
| 33 | int getMaxY();
|
|---|
| 34 |
|
|---|
| 35 | static void setRandomSeed(double seed);
|
|---|
| 36 | static int randomValue(int maxPlusOne);
|
|---|
| 37 |
|
|---|
| 38 | private:
|
|---|
| 39 | void setXCoord(int index,int value) {coordinates[index][0] = value;}
|
|---|
| 40 | void setYCoord(int index,int value) {coordinates[index][1] = value;}
|
|---|
| 41 | void setCoords(int index,int x,int y){coordinates[index][0] = x;
|
|---|
| 42 | coordinates[index][1] = y;}
|
|---|
| 43 | void initialize(int type);
|
|---|
| 44 |
|
|---|
| 45 | int pieceType;
|
|---|
| 46 | int coordinates[4][2];
|
|---|
| 47 |
|
|---|
| 48 | static double randomSeed;
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 | #endif
|
|---|