00001 /********************************************************************** 00002 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of Qtopia Environment. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00012 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00013 ** 00014 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00015 ** 00016 ** Contact info@trolltech.com if any conditions of this licensing are 00017 ** not clear to you. 00018 ** 00019 **********************************************************************/ 00020 00021 00022 #ifndef TPIECE_H 00023 #define TPIECE_H 00024 00025 class TetrixPiece 00026 { 00027 public: 00028 TetrixPiece() {setRandomType();} 00029 TetrixPiece(int type) {initialize(type % 7 + 1);} 00030 00031 void setRandomType() {initialize(randomValue(7) + 1);} 00032 00033 void rotateLeft(); 00034 void rotateRight(); 00035 00036 int getType() {return pieceType;} 00037 int getXCoord(int index) {return coordinates[index][0];} 00038 int getYCoord(int index) {return coordinates[index][1];} 00039 void getCoord(int index,int &x,int&y){x = coordinates[index][0]; 00040 y = coordinates[index][1];} 00041 int getMinX(); 00042 int getMaxX(); 00043 int getMinY(); 00044 int getMaxY(); 00045 00046 static void setRandomSeed(double seed); 00047 static int randomValue(int maxPlusOne); 00048 00049 private: 00050 void setXCoord(int index,int value) {coordinates[index][0] = value;} 00051 void setYCoord(int index,int value) {coordinates[index][1] = value;} 00052 void setCoords(int index,int x,int y){coordinates[index][0] = x; 00053 coordinates[index][1] = y;} 00054 void initialize(int type); 00055 00056 int pieceType; 00057 int coordinates[4][2]; 00058 00059 static double randomSeed; 00060 }; 00061 00062 #endif
1.4.2