-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsplitpea.cpp
35 lines (31 loc) · 859 Bytes
/
splitpea.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
#include "splitpea.h"
SplitPea::SplitPea(QObject *parent) :
Plant("splitPea"), strength(1), property(1),counter(0)
{
}
void SplitPea::seeZombie(int row, int col)
{
// qDebug()<<"come to seeZombie in peashooter";
if (row == myRow && !hasZombie)
hasZombie = true;
// qDebug()<<hasZombie;
}
void SplitPea::sendPea()
{
// qDebug()<<"come to sendPea in peashooter";
// qDebug()<<"row "<<myRow<<" col "<<myCol;
if (hasZombie){
if (counter == 0){
emit emitPea(myRow, myCol, strength, property);
emit emitPea(myRow, myCol, strength, -property);
}
counter = counter >= 25? 0:counter+1;
hasZombie = false;
}
}
QRectF SplitPea::boundingRect() const
{
qreal adjust = 0.5;
return QRectF(-18 - adjust, -22 - adjust,
190 + adjust, 180 + adjust);
}