00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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);
00080 int canMoveTo(int xPosition, int line);
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;
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