-
Notifications
You must be signed in to change notification settings - Fork 0
/
score.cpp
46 lines (42 loc) · 820 Bytes
/
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
#include "score.hpp"
#include <fstream>
#include <iostream>
using namespace std;
string filetosave()
{
int scorei;
fstream file;
file.open("score.txt", ios::in);
file >> scorei;
file.close();
string tmp_text;
tmp_text += "LAST SCORE: " + std::to_string(scorei);
return tmp_text;
}
Score::Score()
{
resolution = Vector2f(800, 600);
window.create(VideoMode(resolution.x, resolution.y), "SCORE HELP", Style::Default);
window.setFramerateLimit(60);
if (!font.loadFromFile("arcade.ttf"))
{
return;
}
score.setFont(font);
score.setFillColor(sf::Color::Red);
score.setString(filetosave());
score.setPosition(sf::Vector2f(800 / 6, 600 / 6));
}
void Score::drawS()
{
window.clear();
window.draw(score);
window.display();
}
void Score::runS()
{
while (window.isOpen())
{
drawS();
}
}