-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoverlay.cpp
25 lines (23 loc) · 943 Bytes
/
overlay.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
#include "overlay.h"
#include "level.h"
#include "player.h"
Overlay::Overlay()
{
int id = QFontDatabase::addApplicationFont(":/fonts/SuperMario256.ttf");
QString fontName = QFontDatabase::applicationFontFamilies(id).at(0);
allTexts["health"] = Text("Vies : ♥♥♥", 40, 20, 30, fontName, "white");
allTexts["level"] = Text("Niveau 1", 450, 20, 30, fontName, "white");
allTexts["time"] = Text("60:00", 1000, 20, 30, fontName, "white");
}
void Overlay::update(Level * lvl) {
int livesLeft = lvl->getPlayer()->getLivesLeft();
int levelId = lvl->getLevelId();
int timeLeft = lvl->timeleft();
QString livesLeftSentence = "Vies : ";
for(int i = 0; i<livesLeft; i++) {
livesLeftSentence.append("♥");
}
allTexts["health"].setSentence(livesLeftSentence);
allTexts["level"].setSentence("Niveau "+QString::number(levelId));
allTexts["time"].setSentence(QString::number(timeLeft));
}