-
Notifications
You must be signed in to change notification settings - Fork 0
/
lives.cpp
62 lines (56 loc) · 1.6 KB
/
lives.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include "lives.h"
#include <QFont>
#include "game.h"
#include <QDebug>
extern Game *game;
Lives::Lives()
{
lives = 3;
setPlainText("Lives: "+ QString::number(lives));
setDefaultTextColor(Qt::white);
setPos(100, 950);
setTextWidth(100);
setFont(QFont ("Arial", 14));
}
int Lives::getlives()
{
return lives;
}
void Lives::decreaselife()
{
lives--;
setPlainText("Lives: "+ QString::number(lives));
if (lives == 0) //if lives reach zero we lose
{
game->pacman->setlose();
game->player->stop();
//Win.setPlainText("You Lose");
//Win.setDefaultTextColor(Qt::white);
//Win.setPos(700, 960);
//Win.setFont(QFont ("Arial", 16));
//scene()->addItem(&Win);
//background->stop();
setPlainText("Lives: "+QString::number(lives));
game->deletelife();
msgBox.setText("Game Over, you lost :(");
msgBox.exec();
exit(0);
}
else //if lives more than zero then remove a life in text item and life symbol
{
game->deletelife();
game->pacman->setcolumn(13);
game->pacman->setrow(23);
game->ghosts[0]->setrow(14);
game->ghosts[0]->setcolumn(13);
game->ghosts[0]->setPos(10+30*13, 20+30*14);
game->ghosts[1]->setrow(14);
game->ghosts[1]->setcolumn(12);
game->ghosts[1]->setPos(10+30*12, 20+30*14);
game->ghosts[2]->setrow(14);
game->ghosts[2]->setcolumn(14);
game->ghosts[2]->setPos(10+30*14, 20+30*14);
game->pacman->reset();
}
setPlainText("Lives: "+QString::number(lives));
}