-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHighScoreScreen.cpp
83 lines (72 loc) · 1.98 KB
/
HighScoreScreen.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include <iostream>
#include <string>
#include "../HighScoreScreen.h"
#include <SFML/Graphics.hpp>
#include "../GameEngine.h"
#include "../HighScore.h"
#define width 1366
#define height 768
void Screen::HighScore()
{
sf::Texture highscoreTexture;
if (!highscoreTexture.loadFromFile("resources/background.png"))
std::cout << "Not working" << std::endl;
sf::Sprite HST;
HST.setTexture(highscoreTexture);
sf::RenderWindow app(sf::VideoMode(1366, 768), "High Score");
sf::Font font;
if (!font.loadFromFile("resources/numberfont.ttf"))
{
std::cout << "Couldn't load font";
}
sf::Text heading;
sf::Text text[3];
std::string getName[3];
std::string getScore[3];
Highscore::Get(getName, getScore);
while (app.isOpen())
{
sf::Event event;
while (app.pollEvent(event))
{
if (event.type == sf::Event::Closed)
app.close();
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
{
app.close();
Game::start();
}
}
for (int i = 0;i < 3;i++)
{
std::transform(getName[i].begin(), getName[i].end(), getName[i].begin(), ::toupper);
}
heading.setFont(font);
heading.setColor(sf::Color::Black);
heading.setString("HIGHSCORES");
heading.setScale(3, 3);
heading.setPosition(sf::Vector2f(width / 4, height / 6));
text[0].setFont(font);
text[0].setColor(sf::Color::Red);
text[0].setString(getName[0] +"\t\t\t" +getScore[0]);
text[0].setScale(2, 2);
text[0].setPosition(sf::Vector2f(width / 8, height / 3));
text[1].setFont(font);
text[1].setColor(sf::Color::Blue);
text[1].setString(getName[1] + "\t\t\t" + getScore[1]);
text[1].setScale(2, 2);
text[1].setPosition(sf::Vector2f(width / 8, height / 2));
text[2].setFont(font);
text[2].setColor(sf::Color::Yellow);
text[2].setString(getName[2] + "\t\t\t" + getScore[2]);
text[2].setScale(2, 2);
text[2].setPosition(sf::Vector2f(width / 8, height / 1.5));
app.clear();
app.draw(HST);
app.draw(heading);
app.draw(text[0]);
app.draw(text[1]);
app.draw(text[2]);
app.display();
}
}