-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore.cpp
49 lines (42 loc) · 1.04 KB
/
score.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
#include "score.h"
#include "enemy.h"
#include "player.h"
#include "gameloop.h"
#include "bullet.h"
#include <QFont>
class Enemy;
class GameLoop;
class Bullet;
class Player;
Score::Score(QGraphicsItem *parent) : QGraphicsTextItem(parent)
{
// set the score
this->score = 0;
// draw text
setPlainText("SCORE: " + QString::number(this->score) + "\nSPACEBAR TO SHOOT\nARROWS TO MOVE\n");
setDefaultTextColor(0x00e27d09);
setFont(QFont("times", 15));
}
void Score::ft_increase(int flag)
{
if (flag == 1)
{
this->score += 10;
setPlainText("SCORE: " + QString::number(this->score) + "\nSPACEBAR TO SHOOT\nARROWS TO MOVE\n");
}
if (flag == 2)
{
if (this->score >= 40)
{
setPlainText("YOU WIN");
setFont(QFont("times", 60));
setPos(300, 400);
}
else
{
setPlainText("YOU LOSE");
setFont(QFont("times", 60));
setPos(300, 400);
}
}
}