forked from ZhouBox/air_plane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bloodsupply.cpp
58 lines (42 loc) · 904 Bytes
/
bloodsupply.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
#include "bloodsupply.h"
BloodSupply::BloodSupply(uint speed, QGraphicsScene *scene, QGraphicsItem *parent):
Flyer(speed, scene, parent),
m_pic(QPixmap(":/image/blood.png"))
{
}
BloodSupply::~BloodSupply()
{
}
QRectF BloodSupply::boundingRect() const
{
return m_pic.rect();
}
void BloodSupply::paint(QPainter *painter, const QStyleOptionGraphicsItem */*option*/, QWidget */*widget*/)
{
painter->drawPixmap(0,0,m_pic);
}
void BloodSupply::autofly()
{
if (!checkPos(Behind)) {
posLost();
return;
}
QPointF t = scenePos();
t.ry() += m_speed;
setPos(t);
doCollide();
}
void BloodSupply::advance(int)
{
if (!checkPos(Behind)) {
posLost();
return;
}
QPointF t = scenePos();
t.ry() += m_speed;
setPos(t);
}
int BloodSupply::name() const
{
return GlobalParameter::instance()->bloodSupplyClassFlag;
}