-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathsnowpea.cpp
More file actions
36 lines (33 loc) · 744 Bytes
/
Copy pathsnowpea.cpp
File metadata and controls
36 lines (33 loc) · 744 Bytes
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
#include "snowpea.h"
SnowPea::SnowPea()
{
atk = 25;
hp = 300;
time = int(1.4 * 1000 / 33);
setMovie(":/images/SnowPea.gif");
}
void SnowPea::advance(int phase)
{
if (!phase)
return;
update();
if (hp <= 0)
delete this;
else if (++counter >= time)
{
counter = 0;
if (!collidingItems().isEmpty())
{
Pea *pea = new Pea(atk, true);
pea->setX(x() + 32);
pea->setY(y());
scene()->addItem(pea);
return;
}
}
}
bool SnowPea::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const
{
Q_UNUSED(mode)
return other->type() == Zombie::Type && qFuzzyCompare(other->y(), y());
}