-
Notifications
You must be signed in to change notification settings - Fork 0
/
puzzlewidget.h
60 lines (52 loc) · 1.3 KB
/
puzzlewidget.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
#ifndef PUZZLEWIDGET_H
#define PUZZLEWIDGET_H
#include <QList>
#include <QPoint>
#include <QPixmap>
#include <QWidget>
#include <QMouseEvent>
class MainWindow;
class Movements;
class PuzzleWidget : public QWidget
{
Q_OBJECT
public:
PuzzleWidget(QWidget * Parent = 0,
const QPoint PiecesNumber = QPoint(3, 3),
int difficulty= 0,
const QSize WidgetSize = QSize(512, 384));
void addPieces(const QPixmap&image = QPixmap());
// TODO : use an enum to specify the game difficulty
void scramble();
void keyPressed(int key);
public slots:
void undo(void);
void redo(void);
signals:
void puzzleCompleted();
void blockMoved();
void moveCounter(int moves);
void gameStarted();
protected:
void paintEvent(QPaintEvent *);
void mousePressEvent(QMouseEvent *);
private:
MainWindow *parent;
int findPiece(const QRect &) const;
QRect findFreePiece(void) const;
QRect findPieceToMove(const QRect) const;
const QRect targetSquare(const QPoint &) const;
QList<QPixmap> piecePixmaps;
QList<QRect> pieceRects;
QList<QPoint> pieceLocations;
QRect highlightedRect;
int inPlace;
QPoint pnt;
QPoint relation;
QSize *widgetSize;
Movements *history;
bool isGameStarted;
int diff;
int moves;
};
#endif