-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoreBoard.cpp
More file actions
52 lines (42 loc) · 1.02 KB
/
Copy pathScoreBoard.cpp
File metadata and controls
52 lines (42 loc) · 1.02 KB
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
#include "ScoreBoard.h"
ScoreBoard::ScoreBoard(float width, float height)
{
if (!font.loadFromFile("BAUHS93.TTF"))
{
//handle error
}
menu[0].setFont(font);
menu[0].setFillColor(sf::Color::Red);
menu[0].setString("BACK TO MENU");
menu[0].setPosition(sf::Vector2f(width / 2, height / (max_menu + 1) * 1));
menu[1].setFont(font);
menu[1].setFillColor(sf::Color::White);
menu[1].setString("Option");
menu[1].setPosition(sf::Vector2f(width / 2, height / (max_menu + 1) * 2));
selectItemIndex = 0;
}
void ScoreBoard::toDraw(sf::RenderWindow& window)
{
for (int i = 0; i < max_menu; i++)
{
window.draw(menu[i]);
}
}
void ScoreBoard::moveRight()
{
if (selectItemIndex - 1 >= 0)
{
menu[selectItemIndex].setFillColor(sf::Color::White);
selectItemIndex--;
menu[selectItemIndex].setFillColor(sf::Color::Red);
}
}
void ScoreBoard::moveLeft()
{
if (selectItemIndex + 1 <= 1)
{
menu[selectItemIndex].setFillColor(sf::Color::White);
selectItemIndex++;
menu[selectItemIndex].setFillColor(sf::Color::Red);
}
}