Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

gtetrix.h

Go to the documentation of this file.
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 GTETRIX_H
00023 #define GTETRIX_H
00024 
00025 #include "tpiece.h"
00026 
00027 
00028 class GenericTetrix
00029 {
00030 public:
00031     GenericTetrix(int boardWidth = 10,int boardHeight = 22);
00032     virtual ~GenericTetrix();
00033 
00034     void clearBoard(int fillRandomLines = 0);
00035     void revealNextPiece(int revealIt);
00036     void updateBoard(int x1,int y1,int x2,int y2,int dontUpdateBlanks = 0);
00037     void updateNext(){if (showNext) showNextPiece();}
00038     void hideBoard();
00039     void showBoard();
00040     void fillRandom(int line);
00041 
00042     void moveLeft(int steps = 1);
00043     void moveRight(int steps = 1);
00044     void rotateLeft();
00045     void rotateRight();
00046     void dropDown();
00047     void oneLineDown();
00048     void newPiece();
00049     void removePiece();
00050 
00051     int  noOfClearLines()                     {return nClearLines;}
00052     int  getLinesRemoved()                    {return nLinesRemoved;}
00053     int  getPiecesDropped()                   {return nPiecesDropped;}
00054     int  getScore()                           {return score;}
00055     int  getLevel()                           {return level;}
00056     int  boardHeight()                        {return height;}
00057     int  boardWidth()                         {return width;}
00058 
00059     virtual void drawSquare(int x,int y,int value) = 0;
00060     virtual void gameOver() = 0;
00061 
00062     virtual void startGame(int gameType = 0,int fillRandomLines = 0);
00063     virtual void drawNextSquare(int x,int y,int value);
00064     virtual void pieceDropped(int dropHeight);
00065     virtual void updateRemoved(int noOfLines);
00066     virtual void updateScore(int newScore);
00067     virtual void updateLevel(int newLevel);
00068 
00069 private:
00070     void  draw(int x, int y, int value){drawSquare(x,height - y,value);}
00071     void  removeFullLines();
00072     void  removeLine(int line);
00073     void  showPiece();
00074     void  erasePiece();
00075     void  internalPieceDropped(int dropHeight);
00076     void  gluePiece();
00077     void  showNextPiece(int erase = 0);
00078     void  eraseNextPiece(){showNextPiece(1);};
00079     int   canPosition(TetrixPiece &piece);    // Returns a boolean value.
00080     int   canMoveTo(int xPosition, int line); // Returns a boolean value.
00081     void  moveTo(int xPosition,int line);
00082     void  position(TetrixPiece &piece);
00083     void  optimizedMove(int newPos, int newLine,TetrixPiece &newPiece);
00084     
00085     int  &board(int x,int y){return boardPtr[width*y + x];}
00086 
00087     TetrixPiece currentPiece;
00088     TetrixPiece nextPiece;
00089     int         currentLine;
00090     int         currentPos;
00091     int         showNext;                    // Boolean variable.
00092     int         nLinesRemoved;
00093     int         nPiecesDropped;
00094     int         score;
00095     int         level;
00096     int         gameID;
00097     int         nClearLines;
00098     int         width;
00099     int         height;
00100     int         *boardPtr;
00101 };
00102 
00103 
00104 #endif

Generated on Sat Nov 5 16:17:27 2005 for OPIE by  doxygen 1.4.2