-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathendlessgamewidget.h
160 lines (131 loc) · 3.42 KB
/
endlessgamewidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#ifndef ENDLESSGAMEWIDGET_H
#define ENDLESSGAMEWIDGET_H
#include "abstractpixmapwidget.h"
#include "abstractrule.h"
#include "connections.h"
// File must include
#include <QPointF>
// Forward declaration
class QPainter;
class QTimer;
class Ball;
class CoreController;
class EffectPainter;
class GestureController;
class AbstractGameBoardInfo;
class AbstractProgressBarItem;
class AbstractItem;
class AbstractBonusItem;
class IntegerItem;
class SwapClassicGameRule;
class SwapClassicGameSavedInfo;
/**
* @brief A class to play an endless game.
*/
class EndlessGameWidget : public AbstractPixmapWidget
{
Q_OBJECT
public:
/**
* @brief Constructor with the gesture.
*/
EndlessGameWidget(AbstractRule::Gesture gesture);
/**
* @brief Destructor.
*/
~EndlessGameWidget();
virtual void makePixmap(
#ifdef USE_PIXMAP
QPixmap& pixmap,
#else
QPainter* painter,
#endif
int width,
int height);
virtual void makeBasicPixmap(
#ifdef USE_PIXMAP
QPixmap& pixmap,
#else
QPainter* painter,
#endif
int width,
int height);
virtual void addEffect(
#ifdef USE_PIXMAP
QPixmap& pixmap,
#else
QPainter* painter,
#endif
int width,
int height);
virtual QPointF toScene(double xRate, double yRate);
virtual void dealPressed(QPointF mousePos,
Qt::MouseButton button);
virtual void dealMoved(QPointF mousePos,
Qt::MouseButton button);
virtual void dealReleased(QPointF mousePos,
Qt::MouseButton button);
virtual void getForcus();
virtual void loseForcus(){}
private:
// Rule of the game
AbstractRule *rule;
// Infomation of the gameboard
AbstractGameBoardInfo *gameboardInfo;
// Core controller which controls the balls
CoreController *controller;
// Gesture controller which connects the gesture
// of the user to the core controller
GestureController *gestureController;
// A painter to paint the effects of the game
EffectPainter *effectPainter;
// A timer to send signals to advance the game
QTimer *t;
// Count of the frame which may used to paint
int frameCount;
// Items of the game
IntegerItem *hightestScore;
IntegerItem *currentLevel;
AbstractProgressBarItem *progressBar;
AbstractBonusItem *flame;
AbstractBonusItem *star;
AbstractItem *hint;
AbstractItem *resetItem;
AbstractItem *exitItem;
// A vector stores the items,
// used to paint and release the space
QVector <AbstractItem *> myItems;
// A value records the item at the
// position which user press
AbstractItem *itemAtPressPos;
// Current position of the mouse,
// used to show the hints
QPointF currentPos;
// Show the hint
void showHint();
// Quit game
void quitGame();
// Next stage
void nextStage();
// Get the index of this game
int getIndex();
private slots:
// Advance
void advance();
// Reset
void reset();
// Deal stable eliminate
// The connections are the balls which will be eliminated
void dealStableEliminate(Connections connections);
// Deal user moving eliminate
// The connections are the balls which will be eliminated
// if user release the mouse
void dealUserMovingEliminate(Connections connections);
// Called when some balls are eliminated
void eliminated(int count);
// Call after a good move is made
void goodMove();
// Call after a bad move is made
void badMove();
};
#endif // ENDLESSGAMEWIDGET_H