-
Notifications
You must be signed in to change notification settings - Fork 0
/
SunflowerBoard.cpp
44 lines (37 loc) · 1.06 KB
/
SunflowerBoard.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
#include "Sunflowerboard.h"
SunflowerBoard::SunflowerBoard(QGraphicsItem* parent) : QObject(), PlantBoard (50, false, false, parent)
{
setPixmap(QPixmap(":/images/sunflowerUnSelected.jpg"));
setPos(155,8);
}
void SunflowerBoard::slotPlayerScore(int playerScore)
{
if (price <= playerScore){
isSelectable = true;
setPixmap(QPixmap(":/images/sunflowerSelectable.jpg"));
}
else{
isSelectable = false;
setPixmap(QPixmap(":/images/sunflowerUnSelected.jpg"));
}
}
void SunflowerBoard::isPlaced()
{
isSelected = false;
emit UnselectSunflower();
}
void SunflowerBoard::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
//first we check that plant is selectable
if(isSelectable && !(isSelected)){
isSelected = true;
//set selected picture
setPixmap(QPixmap(":/images/sunflowerSelected.jpg"));
emit sunflowerSellected();
}
else if ( isSelected ){
isSelected = false;
setPixmap(QPixmap(":/images/sunflowerSelectable.jpg"));
emit UnselectSunflower();
}
}