-
Notifications
You must be signed in to change notification settings - Fork 0
/
guitile.h
64 lines (51 loc) · 1.84 KB
/
guitile.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
#ifndef GUITILE_H
#define GUITILE_H
#include <QGraphicsRectItem>
#include <QGraphicsSimpleTextItem>
#include <QGraphicsSceneMouseEvent>
#include "graphicswindow.h"
#include <QFont>
//#include <QObject>
using namespace std;
class GraphicsWindow;
/**
* This class is used to keep track of one graphic tile. Inherits from QGraphicsRectItem.
* @author Tam Henry Le Nguyen */
class GUITile : public QObject, public QGraphicsRectItem {
Q_OBJECT
public:
GUITile(); /** Default Constructor */
GUITile(GraphicsWindow *p, int val, qreal nx, qreal ny, qreal w, qreal h); /** Constructor with parameters */
~GUITile(); /** Destructor */
void mousePressEvent(QGraphicsSceneMouseEvent* event); /** when tile is clicked on*/
int getValue(); /** Value accessor */
double getxCord(); /** X Coordinate Accessor */
double getyCord(); /** Y Coordinate Accessor */
int getWidth(); /** Width Accessor*/
int getHeight(); /** Height Accessor */
QTimer *getTimer();
void setxCord(double x); /** X Coordinate Resetter */
void setyCord(double y); /** Y Coordinate Resetter */
void setVelocityX(double vx);
void setVelocityY(double vy);
void setDestinationX(double dx);
void setDestinationY(double dy);
private:
GraphicsWindow *parent; /** Pointer to the window the element is in*/
QGraphicsSimpleTextItem* numbers; /** The Graphical display of the number */
int value; /** what number is the guitile*/
double xCord; /** the upper left x coordinate of the tile*/
double yCord; /** the upper left y coordinate of the tile*/
int width; /** the width of the tile*/
int height; /** the height of the tile*/
double velocityX;
double velocityY;
double destinationX;
double destinationY;
int counter;
QTimer *timer; /** Timer */
QGraphicsSceneMouseEvent* event; /** to handle the event */
public slots:
void moveTilesAnimate(); /** Used to animate tiles */
};
#endif