1 | /****************************************************************************
|
---|
2 | ** $Id: qtetrixb.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 QTETRIXB_H
|
---|
12 | #define QTETRIXB_H
|
---|
13 |
|
---|
14 | #include "gtetrix.h"
|
---|
15 | #include <qframe.h>
|
---|
16 |
|
---|
17 | class QTimer;
|
---|
18 |
|
---|
19 | class QTetrixBoard : public QFrame, public GenericTetrix
|
---|
20 | {
|
---|
21 | Q_OBJECT
|
---|
22 | public:
|
---|
23 | QTetrixBoard( QWidget *parent=0, const char *name=0 );
|
---|
24 |
|
---|
25 | void gameOver();
|
---|
26 | void startGame(int gameType = 0,int fillRandomLines = 0);
|
---|
27 |
|
---|
28 | public slots:
|
---|
29 | void timeout();
|
---|
30 | void updateNext() { GenericTetrix::updateNext(); }
|
---|
31 | void key(QKeyEvent *e) { keyPressEvent(e); }
|
---|
32 | void start() { startGame(); }
|
---|
33 | void pause();
|
---|
34 |
|
---|
35 | signals:
|
---|
36 | void gameOverSignal();
|
---|
37 | void drawNextSquareSignal(int x,int y,QColor *color1);
|
---|
38 | void updateRemovedSignal(int noOfLines);
|
---|
39 | void updateScoreSignal(int score);
|
---|
40 | void updateLevelSignal(int level);
|
---|
41 |
|
---|
42 | public: // until we have keyboard focus, should be protected
|
---|
43 | void keyPressEvent( QKeyEvent * );
|
---|
44 |
|
---|
45 | private:
|
---|
46 | void drawContents( QPainter * );
|
---|
47 | void resizeEvent( QResizeEvent * );
|
---|
48 | void drawSquare(int x,int y,int value);
|
---|
49 | void drawNextSquare(int x,int y,int value);
|
---|
50 | void updateRemoved(int noOfLines);
|
---|
51 | void updateScore(int newScore);
|
---|
52 | void updateLevel(int newLlevel);
|
---|
53 | void pieceDropped(int dropHeight);
|
---|
54 | void updateTimeoutTime();
|
---|
55 |
|
---|
56 | QTimer *timer;
|
---|
57 |
|
---|
58 | int xOffset,yOffset;
|
---|
59 | int blockWidth,blockHeight;
|
---|
60 | int timeoutTime;
|
---|
61 | bool noGame;
|
---|
62 | bool isPaused;
|
---|
63 | bool waitingAfterLine;
|
---|
64 |
|
---|
65 | QColor colors[7];
|
---|
66 | QPainter *paint;
|
---|
67 | QWidget *paint_widget;
|
---|
68 | };
|
---|
69 |
|
---|
70 | #endif
|
---|