-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscore.cpp
More file actions
44 lines (33 loc) · 844 Bytes
/
score.cpp
File metadata and controls
44 lines (33 loc) · 844 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
#include "Score.h"
#include <QFont>
#include <game.h>
#include <math.h>
extern Game * game;
Score::Score(QGraphicsItem *parent): QGraphicsTextItem(parent){
score = 0;
setPlainText(QString("Score: ") + QString::number(score));
setDefaultTextColor(Qt::blue);
setFont(QFont("times",16));
}
void Score::increase(){
score++;
if (score > game->max_score)
game->max_score = score;
setPlainText(QString("Score: ") + QString::number(score));
if (div(score, 20).rem == 0)
{
game->enemy_speed -= 250;
game->enemy_move_speed++;
game->timer->start(game->enemy_speed);
}
}
void Score::decrease(int amount)
{
score -= amount;
if (score < 0)
score = 0;
setPlainText(QString("Score: ") + QString::number(score));
}
int Score::getScore(){
return score;
}