-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwalnut.cpp
More file actions
46 lines (37 loc) · 865 Bytes
/
walnut.cpp
File metadata and controls
46 lines (37 loc) · 865 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
37
38
39
40
41
42
43
44
45
46
#include "walnut.h"
int Walnut::seedingTime = 30000;
Walnut::Walnut(QRect *plant_row)
{
//walnut properties
life = 72;
cost = 50;
plantDamage = 0;
fireRate = 0;
//Sets up position based on plant_row
this->setPos(plant_row->x(),plant_row->y()+10);
//loads walnut pixmap
walnutImage = new QPixmap(":/Images/walnut");
}
Walnut::~Walnut()
{
delete walnutImage;
}
QRectF Walnut::boundingRect() const
{
return QRectF(0,0,walnutImage->width(),walnutImage->height());
}
void Walnut::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
//draws walnutImage
painter->drawPixmap(boundingRect(),*walnutImage,boundingRect());
}
void Walnut::advance(int phase)
{
if(!phase) return;
//Deletes instance if life is 0 or less
if(life <= 0)
{
delete this;
return;
}
}