/
life.cpp
37 lines (30 loc) · 870 Bytes
/
life.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
/** @file Life.cpp
* @brief Contains the implementation for the Life class.
*
* Implements the slots of the Heart class using objects.
*/
#include"Life.h"
#include<QFont>
#include"gameboard.h"
extern GameBoard* board;
/** Constructor for the level*/
Life::Life(QGraphicsItem *parent): QGraphicsTextItem(parent)
{
health = 5 ;
setPlainText(QString("Whale Remaining: ")+QString::number(health));
setFont(QFont("Comic Sans MS", 15));
setDefaultTextColor(Qt::red);
}
/** Function to increase the life*/
void Life::increase(){
health++;
setPlainText(QString("Whale Remaining: ")+QString::number(health));
}
/** Function to decrease the life*/
void Life::decrease(){
if (health<1){
board->GameOver();
}
health--;
setPlainText(QString("Whale Remaining: ")+QString::number(health));
}