summaryrefslogtreecommitdiff
path: root/noncore/games/tetrix/gtetrix.h
Unidiff
Diffstat (limited to 'noncore/games/tetrix/gtetrix.h') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/tetrix/gtetrix.h104
1 files changed, 104 insertions, 0 deletions
diff --git a/noncore/games/tetrix/gtetrix.h b/noncore/games/tetrix/gtetrix.h
new file mode 100644
index 0000000..520dd89
--- a/dev/null
+++ b/noncore/games/tetrix/gtetrix.h
@@ -0,0 +1,104 @@
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 GTETRIX_H
23#define GTETRIX_H
24
25#include "tpiece.h"
26
27
28class GenericTetrix
29{
30public:
31 GenericTetrix(int boardWidth = 10,int boardHeight = 22);
32 virtual ~GenericTetrix();
33
34 void clearBoard(int fillRandomLines = 0);
35 void revealNextPiece(int revealIt);
36 void updateBoard(int x1,int y1,int x2,int y2,int dontUpdateBlanks = 0);
37 void updateNext(){if (showNext) showNextPiece();}
38 void hideBoard();
39 void showBoard();
40 void fillRandom(int line);
41
42 void moveLeft(int steps = 1);
43 void moveRight(int steps = 1);
44 void rotateLeft();
45 void rotateRight();
46 void dropDown();
47 void oneLineDown();
48 void newPiece();
49 void removePiece();
50
51 int noOfClearLines() {return nClearLines;}
52 int getLinesRemoved() {return nLinesRemoved;}
53 int getPiecesDropped() {return nPiecesDropped;}
54 int getScore() {return score;}
55 int getLevel() {return level;}
56 int boardHeight() {return height;}
57 int boardWidth() {return width;}
58
59 virtual void drawSquare(int x,int y,int value) = 0;
60 virtual void gameOver() = 0;
61
62 virtual void startGame(int gameType = 0,int fillRandomLines = 0);
63 virtual void drawNextSquare(int x,int y,int value);
64 virtual void pieceDropped(int dropHeight);
65 virtual void updateRemoved(int noOfLines);
66 virtual void updateScore(int newScore);
67 virtual void updateLevel(int newLevel);
68
69private:
70 void draw(int x, int y, int value){drawSquare(x,height - y,value);}
71 void removeFullLines();
72 void removeLine(int line);
73 void showPiece();
74 void erasePiece();
75 void internalPieceDropped(int dropHeight);
76 void gluePiece();
77 void showNextPiece(int erase = 0);
78 void eraseNextPiece(){showNextPiece(1);};
79 int canPosition(TetrixPiece &piece); // Returns a boolean value.
80 int canMoveTo(int xPosition, int line); // Returns a boolean value.
81 void moveTo(int xPosition,int line);
82 void position(TetrixPiece &piece);
83 void optimizedMove(int newPos, int newLine,TetrixPiece &newPiece);
84
85 int &board(int x,int y){return boardPtr[width*y + x];}
86
87 TetrixPiece currentPiece;
88 TetrixPiece nextPiece;
89 int currentLine;
90 int currentPos;
91 int showNext; // Boolean variable.
92 int nLinesRemoved;
93 int nPiecesDropped;
94 int score;
95 int level;
96 int gameID;
97 int nClearLines;
98 int width;
99 int height;
100 int *boardPtr;
101};
102
103
104#endif