forked from GeeeekExplorer/PVZ
-
Notifications
You must be signed in to change notification settings - Fork 1
/
footballzombie.cpp
47 lines (44 loc) · 1.02 KB
/
footballzombie.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
#include "footballzombie.h"
FootballZombie::FootballZombie()
{
hp = 1670;
atk = 100 * 33 / 1000;
speed = 80.0 * 33 / 1000 / 2.5;
setMovie(":/images/FootballZombieWalk.gif");
}
void FootballZombie::advance(int phase)
{
if (!phase)
return;
update();
if (hp <= 0)
{
if (state < 2)
{
state = 2;
setMovie(":/images/FootballZombieDie.gif");
setHead(":/images/ZombieHead.gif");
}
else if (movie->currentFrameNumber() == movie->frameCount() - 1)
delete this;
return;
}
QList<QGraphicsItem *> items = collidingItems();
if (!items.isEmpty())
{
Plant *plant = qgraphicsitem_cast<Plant *>(items[0]);
plant->hp -= atk;
if (state != 1)
{
state = 1;
setMovie(":/images/FootballZombieAttack.gif");
}
return;
}
if (state)
{
state = 0;
setMovie(":/images/FootballZombieWalk.gif");
}
setX(x() - speed);
}