-
Notifications
You must be signed in to change notification settings - Fork 0
/
Consumable.cpp
76 lines (59 loc) · 1.13 KB
/
Consumable.cpp
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
#include "Consumable.h"
Consumable::Consumable()
{
QTime time = QTime::currentTime();
qsrand((uint)time.msec());
//setting random coordinates for new power up
int width = 520;
int height = 320;
int NX = width / 20;
int NY = height / 20;
int _rx = ((NX+qrand()) % (NX)) * 20;
int _ry = ((NY+qrand()) % (NY)) * 20;
restX = _rx;
restY = _ry;
}
bool Consumable::getConsumed() const
{
return consumed;
}
void Consumable::setConsumed(bool value)
{
consumed = value;
}
int Consumable::getX() const
{
return restX;
}
int Consumable::getY() const
{
return restY;
}
void Consumable::animationCounter()
{
animCounter++;
if(animCounter>=counterMax)
{
animCounter=0;
}
powerUpPixMap = powerUpImageList[animCounter];
setPixmap(*powerUpPixMap);
}
QRectF Consumable::testRect() const
{
int x=getX();
int y=getY();
int w=pixmap().width();
int h=pixmap().height();
return QRectF(x,y,w,h);
}
void Consumable::isEaten()
{
consumed=true;
}
QString Consumable::getcolor(){
return color;
}
void Consumable::setcolor(QString c){
color=c;
}