forked from SanskritFritz/bubble-chains
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgameitem.h
More file actions
79 lines (51 loc) · 1.88 KB
/
Copy pathgameitem.h
File metadata and controls
79 lines (51 loc) · 1.88 KB
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
#ifndef GAMEITEM_H
#define GAMEITEM_H
#include <QtGui>
#include "defines.h"
const int MAX_ITEMS_COUNT = 6;
const int ITEM_JOCKER = (1 << 4);
const int ITEM_FALLER = (1 << 5);
const int ITEM_SCORE = 1;
const int TARGET_SCORE = 3;
const int FALLER_SCORE = 10;
class GameItem
{
public:
enum ItemState { IdleState, NotAliveState, DyingState, FallingState, BornState,
SelectedState };
GameItem(quint8 id);
~GameItem();
inline quint8 id() const { return myId; }
inline void setId(quint8 newid) { myId = newid; }
inline int dx() const { return myXoff; }
inline int dy() const { return myYoff; }
inline qreal opacity() const { return myOpacity; }
inline void setOpacity(qreal val) { myOpacity = val; }
void advance();
void idle();
inline bool isIdle() const { return myState == IdleState; }
void die();
inline bool isDying() const { return myState == DyingState; }
void scheduleDeath();
inline bool isNotAlive() const { return myState == NotAliveState; }
void fall(int dx, int dy);
inline bool isFalling() const { return myState == FallingState; }
void born();
inline bool isBorning() const { return myState == BornState; }
void select();
inline bool isSelected() const { return myState == SelectedState; }
inline const QPixmap& itemPixmap() const { return itemPixmap(myId); }
static const QPixmap& itemPixmap(int id);
static int count(int id) { return itemsCount[id]; }
static void dropCount() { itemsCount.clear(); }
void draw(QPainter &p, int x, int y);
protected:
quint8 myId;
ItemState myState;
int myCount;
int myXoff, myYoff;
int myDx, myDy;
qreal myOpacity;
static QMap<int,int> itemsCount;
};
#endif // GAMEITEM_H