-
Notifications
You must be signed in to change notification settings - Fork 0
/
JewelDrag.h
54 lines (47 loc) · 1.18 KB
/
JewelDrag.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
/**************************************************************************
** Qt Creator license header template
** Special keywords: dpinol 03/03/2014 2014
** Environment variables:
** To protect a percent sign, use '%'.
**************************************************************************/
#ifndef JEWELDRAG_H
#define JEWELDRAG_H
#include <utils/Vector2D.h>
#include <model/BoardPos.h>
#include <model/JewelSwap.h>
class JewelBoard;
namespace dani {
class Effect;
}
/**
* @brief The JewelDrag class mimicks Candy Crush swipe.
* swap is triggered when finger moves approx half a tile
* (no need to raise finger)
*/
class JewelDrag
{
public:
JewelDrag(JewelBoard &board);
/** Updates board with automatic swipe*/
void update();
/** mouse button down*/
void drag();
/** mouse button up*/
void drop();
/**
* @brief isSwapping
* @return
*/
bool isSwapping() const;
private:
JewelBoard &m_board;
/** Invalid is not dragging*/
Vector2D m_fromPixel;
/** redundant wrt m_fromPixel to avoid recalculation*/
BoardPos m_fromPos;
BoardPos m_toPos;
JewelSwap m_modelSwap;
dani::Effect *m_swapEffect;
// BoardPos m_selected;
};
#endif // JEWELDRAG_H